@oblax/auth 1.0.0 → 2.1.0
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/accounts.d.ts +20 -15
- package/dist/accounts.d.ts.map +1 -1
- package/dist/accounts.js +19 -15
- package/dist/accounts.js.map +1 -1
- package/dist/auth.d.ts +9 -3
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +9 -3
- package/dist/auth.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/keys.d.ts +18 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +19 -0
- package/dist/keys.js.map +1 -0
- package/dist/logs.d.ts +24 -0
- package/dist/logs.d.ts.map +1 -0
- package/dist/logs.js +27 -0
- package/dist/logs.js.map +1 -0
- package/dist/roles.d.ts +14 -4
- package/dist/roles.d.ts.map +1 -1
- package/dist/roles.js +19 -3
- package/dist/roles.js.map +1 -1
- package/dist/session.d.ts +12 -5
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +11 -4
- package/dist/session.js.map +1 -1
- package/dist/types.d.ts +87 -13
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/accounts.d.ts
CHANGED
|
@@ -5,17 +5,17 @@ import type { Account, ConfirmAccountParams, CreateAccountParams, EnableAccountP
|
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
|
-
* // Register a new user
|
|
8
|
+
* // Register a new user: the account starts unconfirmed, and the API mails
|
|
9
|
+
* // a confirmation link
|
|
9
10
|
* const account = await oblax.auth.accounts.create({
|
|
10
11
|
* firstName: 'Alice',
|
|
11
12
|
* lastName: 'Smith',
|
|
12
13
|
* email: 'alice@example.com',
|
|
13
|
-
* password: 'secret',
|
|
14
|
-
* role: 'user',
|
|
14
|
+
* password: 'secret-password',
|
|
15
15
|
* })
|
|
16
16
|
*
|
|
17
|
-
* //
|
|
18
|
-
* await oblax.auth.accounts.confirm({ confirmationToken:
|
|
17
|
+
* // On the page the confirmation link opens: confirm with the link's token
|
|
18
|
+
* await oblax.auth.accounts.confirm({ confirmationToken: tokenFromTheLink })
|
|
19
19
|
*
|
|
20
20
|
* // Admin: list all accounts
|
|
21
21
|
* const all = await oblax.auth.accounts.list()
|
|
@@ -34,15 +34,18 @@ export declare class AccountsSubmodule {
|
|
|
34
34
|
private readonly ctx;
|
|
35
35
|
constructor(ctx: OblaxContext);
|
|
36
36
|
/**
|
|
37
|
-
* Registers a new account
|
|
37
|
+
* Registers a new account with the project's default role (`user` unless an
|
|
38
|
+
* admin changed it with `roles.setDefault`).
|
|
38
39
|
*
|
|
39
|
-
* The
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* The account starts unconfirmed (`confirmed: false`), and signing in fails
|
|
41
|
+
* until it is confirmed. The API mails the user a confirmation link; the
|
|
42
|
+
* token in it never reaches the app, so the page the link opens calls
|
|
43
|
+
* `confirm()` with it. An app admin can confirm an account instead.
|
|
42
44
|
*/
|
|
43
45
|
create(params: CreateAccountParams): Promise<Account>;
|
|
44
46
|
/**
|
|
45
|
-
* Confirms account
|
|
47
|
+
* Confirms an account with the token from the link in its confirmation
|
|
48
|
+
* mail.
|
|
46
49
|
*/
|
|
47
50
|
confirm(params: ConfirmAccountParams): Promise<void>;
|
|
48
51
|
/**
|
|
@@ -56,15 +59,17 @@ export declare class AccountsSubmodule {
|
|
|
56
59
|
*/
|
|
57
60
|
enable(params: EnableAccountParams): Promise<boolean>;
|
|
58
61
|
/**
|
|
59
|
-
*
|
|
62
|
+
* Starts a password reset for the given email address: the backend mails
|
|
63
|
+
* the account a link carrying the reset token. The link and the token are
|
|
64
|
+
* never returned to the caller; the API answers 204 No Content, also when
|
|
65
|
+
* no account has that email, so the answer doesn't tell whether one exists.
|
|
60
66
|
*
|
|
61
|
-
* @returns
|
|
62
|
-
* is delivered by the calling service rather than by the backend).
|
|
67
|
+
* @returns Nothing; resolves once the request is accepted.
|
|
63
68
|
*/
|
|
64
|
-
requestPasswordReset(params: RequestPasswordResetParams): Promise<
|
|
69
|
+
requestPasswordReset(params: RequestPasswordResetParams): Promise<void>;
|
|
65
70
|
/**
|
|
66
71
|
* Sets a new password using the token from a password-reset email.
|
|
67
|
-
* Call `requestPasswordReset` first
|
|
72
|
+
* Call `requestPasswordReset` first; the token arrives in the email it sends.
|
|
68
73
|
*/
|
|
69
74
|
resetPassword(params: ResetPasswordParams): Promise<void>;
|
|
70
75
|
}
|
package/dist/accounts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EACV,OAAO,EACP,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EACV,OAAO,EACP,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C;;;;;;;;OAQG;IACG,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAS3D;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1D;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIhC;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAM3D;;;;;;;OAOG;IACG,oBAAoB,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7E;;;OAGG;IACG,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;CAMhE"}
|
package/dist/accounts.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @example
|
|
5
5
|
* ```typescript
|
|
6
|
-
* // Register a new user
|
|
6
|
+
* // Register a new user: the account starts unconfirmed, and the API mails
|
|
7
|
+
* // a confirmation link
|
|
7
8
|
* const account = await oblax.auth.accounts.create({
|
|
8
9
|
* firstName: 'Alice',
|
|
9
10
|
* lastName: 'Smith',
|
|
10
11
|
* email: 'alice@example.com',
|
|
11
|
-
* password: 'secret',
|
|
12
|
-
* role: 'user',
|
|
12
|
+
* password: 'secret-password',
|
|
13
13
|
* })
|
|
14
14
|
*
|
|
15
|
-
* //
|
|
16
|
-
* await oblax.auth.accounts.confirm({ confirmationToken:
|
|
15
|
+
* // On the page the confirmation link opens: confirm with the link's token
|
|
16
|
+
* await oblax.auth.accounts.confirm({ confirmationToken: tokenFromTheLink })
|
|
17
17
|
*
|
|
18
18
|
* // Admin: list all accounts
|
|
19
19
|
* const all = await oblax.auth.accounts.list()
|
|
@@ -33,11 +33,13 @@ export class AccountsSubmodule {
|
|
|
33
33
|
this.ctx = ctx;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Registers a new account
|
|
36
|
+
* Registers a new account with the project's default role (`user` unless an
|
|
37
|
+
* admin changed it with `roles.setDefault`).
|
|
37
38
|
*
|
|
38
|
-
* The
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* The account starts unconfirmed (`confirmed: false`), and signing in fails
|
|
40
|
+
* until it is confirmed. The API mails the user a confirmation link; the
|
|
41
|
+
* token in it never reaches the app, so the page the link opens calls
|
|
42
|
+
* `confirm()` with it. An app admin can confirm an account instead.
|
|
41
43
|
*/
|
|
42
44
|
async create(params) {
|
|
43
45
|
return this.ctx.http.post('/auth/accounts', {
|
|
@@ -45,11 +47,11 @@ export class AccountsSubmodule {
|
|
|
45
47
|
last_name: params.lastName,
|
|
46
48
|
email: params.email,
|
|
47
49
|
password: params.password,
|
|
48
|
-
role: params.role,
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
|
-
* Confirms account
|
|
53
|
+
* Confirms an account with the token from the link in its confirmation
|
|
54
|
+
* mail.
|
|
53
55
|
*/
|
|
54
56
|
async confirm(params) {
|
|
55
57
|
return this.ctx.http.post('/auth/accounts/confirmation', {
|
|
@@ -73,10 +75,12 @@ export class AccountsSubmodule {
|
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
77
|
/**
|
|
76
|
-
*
|
|
78
|
+
* Starts a password reset for the given email address: the backend mails
|
|
79
|
+
* the account a link carrying the reset token. The link and the token are
|
|
80
|
+
* never returned to the caller; the API answers 204 No Content, also when
|
|
81
|
+
* no account has that email, so the answer doesn't tell whether one exists.
|
|
77
82
|
*
|
|
78
|
-
* @returns
|
|
79
|
-
* is delivered by the calling service rather than by the backend).
|
|
83
|
+
* @returns Nothing; resolves once the request is accepted.
|
|
80
84
|
*/
|
|
81
85
|
async requestPasswordReset(params) {
|
|
82
86
|
return this.ctx.http.post('/auth/accounts/reset-password-link', {
|
|
@@ -85,7 +89,7 @@ export class AccountsSubmodule {
|
|
|
85
89
|
}
|
|
86
90
|
/**
|
|
87
91
|
* Sets a new password using the token from a password-reset email.
|
|
88
|
-
* Call `requestPasswordReset` first
|
|
92
|
+
* Call `requestPasswordReset` first; the token arrives in the email it sends.
|
|
89
93
|
*/
|
|
90
94
|
async resetPassword(params) {
|
|
91
95
|
return this.ctx.http.put('/auth/accounts/reset-password', {
|
package/dist/accounts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,CAAC,MAA2B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAU,gBAAgB,EAAE;YACnD,UAAU,EAAE,MAAM,CAAC,SAAS;YAC5B,SAAS,EAAG,MAAM,CAAC,QAAQ;YAC3B,KAAK,EAAO,MAAM,CAAC,KAAK;YACxB,QAAQ,EAAI,MAAM,CAAC,QAAQ;SAC5B,CAAC,CAAA;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,MAA4B;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAO,6BAA6B,EAAE;YAC7D,kBAAkB,EAAE,MAAM,CAAC,iBAAiB;SAC7C,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAY,gBAAgB,CAAC,CAAA;IACvD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,MAA2B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAU,kBAAkB,MAAM,CAAC,EAAE,UAAU,EAAE;YACzE,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,oBAAoB,CAAC,MAAkC;QAC3D,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAO,oCAAoC,EAAE;YACpE,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,CAAC,MAA2B;QAC7C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAO,+BAA+B,EAAE;YAC9D,KAAK,EAAK,MAAM,CAAC,KAAK;YACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/auth.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { SessionSubmodule } from './session.js';
|
|
|
3
3
|
import { AccountsSubmodule } from './accounts.js';
|
|
4
4
|
import { RealmsSubmodule } from './realms.js';
|
|
5
5
|
import { RolesSubmodule } from './roles.js';
|
|
6
|
+
import { LogsSubmodule } from './logs.js';
|
|
7
|
+
import { KeysSubmodule } from './keys.js';
|
|
6
8
|
/**
|
|
7
9
|
* Auth module configuration.
|
|
8
10
|
*/
|
|
@@ -21,12 +23,14 @@ export interface AuthConfig {
|
|
|
21
23
|
/**
|
|
22
24
|
* The Auth module.
|
|
23
25
|
*
|
|
24
|
-
* Exposes
|
|
26
|
+
* Exposes six sub-modules:
|
|
25
27
|
*
|
|
26
|
-
* - `session` — create (authenticated or anonymous), refresh, destroy sessions.
|
|
28
|
+
* - `session` — create (authenticated or anonymous), read, refresh, destroy sessions.
|
|
27
29
|
* - `accounts` — register users, confirm emails, manage passwords.
|
|
28
30
|
* - `realms` — manage authentication realms (multi-tenancy).
|
|
29
|
-
* - `roles` — manage access-level roles within realms.
|
|
31
|
+
* - `roles` — manage access-level roles within realms, and the default role.
|
|
32
|
+
* - `logs` — read the authentication log.
|
|
33
|
+
* - `keys` — fetch the public key that verifies access tokens.
|
|
30
34
|
*
|
|
31
35
|
* @example
|
|
32
36
|
* ```typescript
|
|
@@ -47,6 +51,8 @@ export declare class AuthModule {
|
|
|
47
51
|
readonly accounts: AccountsSubmodule;
|
|
48
52
|
readonly realms: RealmsSubmodule;
|
|
49
53
|
readonly roles: RolesSubmodule;
|
|
54
|
+
readonly logs: LogsSubmodule;
|
|
55
|
+
readonly keys: KeysSubmodule;
|
|
50
56
|
constructor(ctx: OblaxContext, config: AuthConfig);
|
|
51
57
|
}
|
|
52
58
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;IAChC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;IAC9B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;gBAEhB,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU;CA2BlD"}
|
package/dist/auth.js
CHANGED
|
@@ -3,15 +3,19 @@ import { SessionSubmodule } from './session.js';
|
|
|
3
3
|
import { AccountsSubmodule } from './accounts.js';
|
|
4
4
|
import { RealmsSubmodule } from './realms.js';
|
|
5
5
|
import { RolesSubmodule } from './roles.js';
|
|
6
|
+
import { LogsSubmodule } from './logs.js';
|
|
7
|
+
import { KeysSubmodule } from './keys.js';
|
|
6
8
|
/**
|
|
7
9
|
* The Auth module.
|
|
8
10
|
*
|
|
9
|
-
* Exposes
|
|
11
|
+
* Exposes six sub-modules:
|
|
10
12
|
*
|
|
11
|
-
* - `session` — create (authenticated or anonymous), refresh, destroy sessions.
|
|
13
|
+
* - `session` — create (authenticated or anonymous), read, refresh, destroy sessions.
|
|
12
14
|
* - `accounts` — register users, confirm emails, manage passwords.
|
|
13
15
|
* - `realms` — manage authentication realms (multi-tenancy).
|
|
14
|
-
* - `roles` — manage access-level roles within realms.
|
|
16
|
+
* - `roles` — manage access-level roles within realms, and the default role.
|
|
17
|
+
* - `logs` — read the authentication log.
|
|
18
|
+
* - `keys` — fetch the public key that verifies access tokens.
|
|
15
19
|
*
|
|
16
20
|
* @example
|
|
17
21
|
* ```typescript
|
|
@@ -37,6 +41,8 @@ export class AuthModule {
|
|
|
37
41
|
this.accounts = new AccountsSubmodule(ctx);
|
|
38
42
|
this.realms = new RealmsSubmodule(ctx);
|
|
39
43
|
this.roles = new RolesSubmodule(ctx);
|
|
44
|
+
this.logs = new LogsSubmodule(ctx);
|
|
45
|
+
this.keys = new KeysSubmodule(ctx);
|
|
40
46
|
// Wire up automatic token refresh. The HTTP client will call this on every
|
|
41
47
|
// 401 response. session.refresh() updates the platform's stored token, so
|
|
42
48
|
// the retried request will carry the new credentials.
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAkBzC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,UAAU;IAQrB,YAAY,GAAiB,EAAE,MAAkB;QAC/C,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,UAAU,CAClB,0DAA0D;gBACxD,gFAAgF,CACnF,CAAA;QACH,CAAC;QAED,IAAI,CAAC,OAAO,GAAI,IAAI,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;QACvD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAA;QAC1C,IAAI,CAAC,MAAM,GAAK,IAAI,eAAe,CAAC,GAAG,CAAC,CAAA;QACxC,IAAI,CAAC,KAAK,GAAM,IAAI,cAAc,CAAC,GAAG,CAAC,CAAA;QACvC,IAAI,CAAC,IAAI,GAAO,IAAI,aAAa,CAAC,GAAG,CAAC,CAAA;QACtC,IAAI,CAAC,IAAI,GAAO,IAAI,aAAa,CAAC,GAAG,CAAC,CAAA;QAEtC,2EAA2E;QAC3E,0EAA0E;QAC1E,sDAAsD;QACtD,GAAG,CAAC,QAAQ,CAAC,cAAc,GAAG,KAAK,IAAI,EAAE;YACvC,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;gBAC5B,OAAO,IAAI,CAAA;YACb,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC,CAAA;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export { SessionSubmodule } from './session.js';
|
|
|
7
7
|
export { AccountsSubmodule } from './accounts.js';
|
|
8
8
|
export { RealmsSubmodule } from './realms.js';
|
|
9
9
|
export { RolesSubmodule } from './roles.js';
|
|
10
|
-
export
|
|
10
|
+
export { LogsSubmodule } from './logs.js';
|
|
11
|
+
export { KeysSubmodule } from './keys.js';
|
|
12
|
+
export type { SessionTokens, SessionDetails, CreateSessionParams, Account, CreateAccountParams, ConfirmAccountParams, EnableAccountParams, RequestPasswordResetParams, ResetPasswordParams, Realm, ArchivedRealm, CreateRealmParams, UpdateRealmParams, RealmIdParams, RoleType, Role, CreateRoleParams, UpdateRoleParams, RoleIdParams, SetDefaultRoleParams, AuthLog, AuthLogEvent, AuthLogIdParams, PublicKey, } from './types.js';
|
|
11
13
|
/**
|
|
12
14
|
* Auth module factory.
|
|
13
15
|
*
|
|
@@ -32,15 +34,20 @@ export type { SessionTokens, CreateSessionParams, Account, CreateAccountParams,
|
|
|
32
34
|
* await oblax.auth.session.createAnonymous()
|
|
33
35
|
*
|
|
34
36
|
* // Account management
|
|
35
|
-
*
|
|
37
|
+
* await oblax.auth.accounts.create({
|
|
36
38
|
* firstName: 'Bob', lastName: 'Jones',
|
|
37
|
-
* email: 'bob@example.com', password: '
|
|
39
|
+
* email: 'bob@example.com', password: 'secret-password',
|
|
38
40
|
* })
|
|
39
|
-
*
|
|
41
|
+
* // later, on the page the confirmation mail's link opens:
|
|
42
|
+
* await oblax.auth.accounts.confirm({ confirmationToken: tokenFromTheLink })
|
|
40
43
|
*
|
|
41
44
|
* // Realm & role management (admin)
|
|
42
45
|
* const realms = await oblax.auth.realms.list()
|
|
43
46
|
* const roles = await oblax.auth.roles.list()
|
|
47
|
+
*
|
|
48
|
+
* // Auth log and token verification key (admin)
|
|
49
|
+
* const logs = await oblax.auth.logs.list()
|
|
50
|
+
* const { public_key } = await oblax.auth.keys.getPublic()
|
|
44
51
|
* ```
|
|
45
52
|
*/
|
|
46
53
|
export declare function Auth(config: AuthConfig): OblaxModulePlugin<'auth', AuthModule>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,K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,EACb,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EAEb,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EAEpB,OAAO,EACP,YAAY,EACZ,eAAe,EAEf,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,CAO9E"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ export { SessionSubmodule } from './session.js';
|
|
|
4
4
|
export { AccountsSubmodule } from './accounts.js';
|
|
5
5
|
export { RealmsSubmodule } from './realms.js';
|
|
6
6
|
export { RolesSubmodule } from './roles.js';
|
|
7
|
+
export { LogsSubmodule } from './logs.js';
|
|
8
|
+
export { KeysSubmodule } from './keys.js';
|
|
7
9
|
/**
|
|
8
10
|
* Auth module factory.
|
|
9
11
|
*
|
|
@@ -28,15 +30,20 @@ export { RolesSubmodule } from './roles.js';
|
|
|
28
30
|
* await oblax.auth.session.createAnonymous()
|
|
29
31
|
*
|
|
30
32
|
* // Account management
|
|
31
|
-
*
|
|
33
|
+
* await oblax.auth.accounts.create({
|
|
32
34
|
* firstName: 'Bob', lastName: 'Jones',
|
|
33
|
-
* email: 'bob@example.com', password: '
|
|
35
|
+
* email: 'bob@example.com', password: 'secret-password',
|
|
34
36
|
* })
|
|
35
|
-
*
|
|
37
|
+
* // later, on the page the confirmation mail's link opens:
|
|
38
|
+
* await oblax.auth.accounts.confirm({ confirmationToken: tokenFromTheLink })
|
|
36
39
|
*
|
|
37
40
|
* // Realm & role management (admin)
|
|
38
41
|
* const realms = await oblax.auth.realms.list()
|
|
39
42
|
* const roles = await oblax.auth.roles.list()
|
|
43
|
+
*
|
|
44
|
+
* // Auth log and token verification key (admin)
|
|
45
|
+
* const logs = await oblax.auth.logs.list()
|
|
46
|
+
* const { public_key } = await oblax.auth.keys.getPublic()
|
|
40
47
|
* ```
|
|
41
48
|
*/
|
|
42
49
|
export function Auth(config) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAGtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAGtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAmCzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,IAAI,CAAC,MAAkB;IACrC,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,MAAM,CAAC,GAAiB;YACtB,OAAO,IAAI,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACpC,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/keys.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { PublicKey } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Exposes the keys used to sign the project's access tokens, so a backend can
|
|
5
|
+
* verify an Oblax JWT itself without calling Oblax on every request.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const { public_key } = await oblax.auth.keys.getPublic()
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare class KeysSubmodule {
|
|
13
|
+
private readonly ctx;
|
|
14
|
+
constructor(ctx: OblaxContext);
|
|
15
|
+
/** Returns the public key for the calling client's project. */
|
|
16
|
+
getPublic(): Promise<PublicKey>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C;;;;;;;;GAQG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,+DAA+D;IACzD,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;CAGtC"}
|
package/dist/keys.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exposes the keys used to sign the project's access tokens, so a backend can
|
|
3
|
+
* verify an Oblax JWT itself without calling Oblax on every request.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const { public_key } = await oblax.auth.keys.getPublic()
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export class KeysSubmodule {
|
|
11
|
+
constructor(ctx) {
|
|
12
|
+
this.ctx = ctx;
|
|
13
|
+
}
|
|
14
|
+
/** Returns the public key for the calling client's project. */
|
|
15
|
+
async getPublic() {
|
|
16
|
+
return this.ctx.http.get('/auth/keys/public');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=keys.js.map
|
package/dist/keys.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IACxB,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD,+DAA+D;IAC/D,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAY,mBAAmB,CAAC,CAAA;IAC1D,CAAC;CACF"}
|
package/dist/logs.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { AuthLog, AuthLogIdParams } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the authentication log: sign-ins, sign-outs, token refreshes,
|
|
5
|
+
* password resets and account events. The default access rules give these
|
|
6
|
+
* routes to no role, so every caller gets 403 until the project adds a rule
|
|
7
|
+
* (`obx project acl push`); `obx project logs auth` reads the log meanwhile.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const logs = await oblax.auth.logs.list()
|
|
12
|
+
* const failed = logs.filter((l) => l.status === 'failure')
|
|
13
|
+
* const one = await oblax.auth.logs.get({ id: logs[0].id })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class LogsSubmodule {
|
|
17
|
+
private readonly ctx;
|
|
18
|
+
constructor(ctx: OblaxContext);
|
|
19
|
+
/** Returns all auth log entries. */
|
|
20
|
+
list(): Promise<AuthLog[]>;
|
|
21
|
+
/** Fetches a single auth log entry by ID. */
|
|
22
|
+
get(params: AuthLogIdParams): Promise<AuthLog>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../src/logs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE1D;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,oCAAoC;IAC9B,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIhC,6CAA6C;IACvC,GAAG,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;CAGrD"}
|
package/dist/logs.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the authentication log: sign-ins, sign-outs, token refreshes,
|
|
3
|
+
* password resets and account events. The default access rules give these
|
|
4
|
+
* routes to no role, so every caller gets 403 until the project adds a rule
|
|
5
|
+
* (`obx project acl push`); `obx project logs auth` reads the log meanwhile.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const logs = await oblax.auth.logs.list()
|
|
10
|
+
* const failed = logs.filter((l) => l.status === 'failure')
|
|
11
|
+
* const one = await oblax.auth.logs.get({ id: logs[0].id })
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export class LogsSubmodule {
|
|
15
|
+
constructor(ctx) {
|
|
16
|
+
this.ctx = ctx;
|
|
17
|
+
}
|
|
18
|
+
/** Returns all auth log entries. */
|
|
19
|
+
async list() {
|
|
20
|
+
return this.ctx.http.get('/auth/logs');
|
|
21
|
+
}
|
|
22
|
+
/** Fetches a single auth log entry by ID. */
|
|
23
|
+
async get(params) {
|
|
24
|
+
return this.ctx.http.get(`/auth/logs/${params.id}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=logs.js.map
|
package/dist/logs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../src/logs.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IACxB,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD,oCAAoC;IACpC,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAY,YAAY,CAAC,CAAA;IACnD,CAAC;IAED,6CAA6C;IAC7C,KAAK,CAAC,GAAG,CAAC,MAAuB;QAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAU,cAAc,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9D,CAAC;CACF"}
|
package/dist/roles.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { OblaxContext } from '@oblax/core';
|
|
2
|
-
import type { CreateRoleParams, Role, RoleIdParams, UpdateRoleParams } from './types.js';
|
|
2
|
+
import type { CreateRoleParams, Role, RoleIdParams, SetDefaultRoleParams, UpdateRoleParams } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Manages roles across all realms.
|
|
5
5
|
*
|
|
6
|
-
* Roles define an access level (`
|
|
6
|
+
* Roles define an access level (`admin`, `manager`, or `user`) within a realm
|
|
7
7
|
* and are assigned to accounts at registration time. The list endpoint returns
|
|
8
8
|
* all roles regardless of realm; filter by `realm_id` client-side if needed.
|
|
9
9
|
*
|
|
@@ -14,11 +14,14 @@ import type { CreateRoleParams, Role, RoleIdParams, UpdateRoleParams } from './t
|
|
|
14
14
|
*
|
|
15
15
|
* const created = await oblax.auth.roles.create({
|
|
16
16
|
* name: 'editor',
|
|
17
|
-
* type: '
|
|
17
|
+
* type: 'manager',
|
|
18
18
|
* realmId: 'realm-id',
|
|
19
19
|
* })
|
|
20
20
|
*
|
|
21
|
-
* await oblax.auth.roles.update({ id: created.id, name: 'senior-editor', type: '
|
|
21
|
+
* await oblax.auth.roles.update({ id: created.id, name: 'senior-editor', type: 'manager', realmId: 'realm-id' })
|
|
22
|
+
*
|
|
23
|
+
* await oblax.auth.roles.setDefault({ id: created.id, default: true })
|
|
24
|
+
* const fallback = await oblax.auth.roles.getDefault()
|
|
22
25
|
* await oblax.auth.roles.delete({ id: created.id })
|
|
23
26
|
* ```
|
|
24
27
|
*/
|
|
@@ -36,6 +39,13 @@ export declare class RolesSubmodule {
|
|
|
36
39
|
* Returns `void` (HTTP 204).
|
|
37
40
|
*/
|
|
38
41
|
update(params: UpdateRoleParams): Promise<void>;
|
|
42
|
+
/** Returns the default role: the one new accounts get when they don't name a role. */
|
|
43
|
+
getDefault(): Promise<Role>;
|
|
44
|
+
/**
|
|
45
|
+
* Makes a role the default (`default: true`) or unsets it (`default: false`).
|
|
46
|
+
* Requires admin privileges. Resolves to `true` when the role changed.
|
|
47
|
+
*/
|
|
48
|
+
setDefault(params: SetDefaultRoleParams): Promise<boolean>;
|
|
39
49
|
/** Deletes a role by ID. Requires admin privileges. */
|
|
40
50
|
delete(params: RoleIdParams): Promise<void>;
|
|
41
51
|
}
|
package/dist/roles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../src/roles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EACJ,YAAY,EACZ,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAEnB
|
|
1
|
+
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../src/roles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EACJ,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,2CAA2C;IACrC,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAI7B,mCAAmC;IAC7B,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,wEAAwE;IAClE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrD;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrD,sFAAsF;IAChF,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC;;;OAGG;IACG,UAAU,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAMhE,uDAAuD;IACjD,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlD"}
|
package/dist/roles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Manages roles across all realms.
|
|
3
3
|
*
|
|
4
|
-
* Roles define an access level (`
|
|
4
|
+
* Roles define an access level (`admin`, `manager`, or `user`) within a realm
|
|
5
5
|
* and are assigned to accounts at registration time. The list endpoint returns
|
|
6
6
|
* all roles regardless of realm; filter by `realm_id` client-side if needed.
|
|
7
7
|
*
|
|
@@ -12,11 +12,14 @@
|
|
|
12
12
|
*
|
|
13
13
|
* const created = await oblax.auth.roles.create({
|
|
14
14
|
* name: 'editor',
|
|
15
|
-
* type: '
|
|
15
|
+
* type: 'manager',
|
|
16
16
|
* realmId: 'realm-id',
|
|
17
17
|
* })
|
|
18
18
|
*
|
|
19
|
-
* await oblax.auth.roles.update({ id: created.id, name: 'senior-editor', type: '
|
|
19
|
+
* await oblax.auth.roles.update({ id: created.id, name: 'senior-editor', type: 'manager', realmId: 'realm-id' })
|
|
20
|
+
*
|
|
21
|
+
* await oblax.auth.roles.setDefault({ id: created.id, default: true })
|
|
22
|
+
* const fallback = await oblax.auth.roles.getDefault()
|
|
20
23
|
* await oblax.auth.roles.delete({ id: created.id })
|
|
21
24
|
* ```
|
|
22
25
|
*/
|
|
@@ -51,6 +54,19 @@ export class RolesSubmodule {
|
|
|
51
54
|
realm_id: params.realmId,
|
|
52
55
|
});
|
|
53
56
|
}
|
|
57
|
+
/** Returns the default role: the one new accounts get when they don't name a role. */
|
|
58
|
+
async getDefault() {
|
|
59
|
+
return this.ctx.http.get('/auth/roles/default');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Makes a role the default (`default: true`) or unsets it (`default: false`).
|
|
63
|
+
* Requires admin privileges. Resolves to `true` when the role changed.
|
|
64
|
+
*/
|
|
65
|
+
async setDefault(params) {
|
|
66
|
+
return this.ctx.http.patch(`/auth/roles/${params.id}/default`, {
|
|
67
|
+
default: params.default,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
54
70
|
/** Deletes a role by ID. Requires admin privileges. */
|
|
55
71
|
async delete(params) {
|
|
56
72
|
return this.ctx.http.delete(`/auth/roles/${params.id}`);
|
package/dist/roles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.js","sourceRoot":"","sources":["../src/roles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"roles.js","sourceRoot":"","sources":["../src/roles.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,cAAc;IACzB,YAA6B,GAAiB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AED,uDAAuD;IACvD,KAAK,CAAC,MAAM,CAAC,MAAoB;QAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAO,eAAe,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;IAC/D,CAAC;CACF"}
|
package/dist/session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OblaxContext } from '@oblax/core';
|
|
2
|
-
import type { CreateSessionParams, SessionTokens } from './types.js';
|
|
2
|
+
import type { CreateSessionParams, SessionDetails, SessionTokens } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Manages the authenticated session for a specific realm.
|
|
5
5
|
*
|
|
@@ -20,6 +20,10 @@ import type { CreateSessionParams, SessionTokens } from './types.js';
|
|
|
20
20
|
* // Renew before expiry
|
|
21
21
|
* await oblax.auth.session.refresh()
|
|
22
22
|
*
|
|
23
|
+
* // Who is signed in?
|
|
24
|
+
* const details = await oblax.auth.session.get()
|
|
25
|
+
* if (details?.authenticated) console.log(details.user.email)
|
|
26
|
+
*
|
|
23
27
|
* // Log out
|
|
24
28
|
* await oblax.auth.session.destroy()
|
|
25
29
|
* ```
|
|
@@ -68,11 +72,14 @@ export declare class SessionSubmodule {
|
|
|
68
72
|
*/
|
|
69
73
|
destroy(): Promise<void>;
|
|
70
74
|
/**
|
|
71
|
-
* Returns the
|
|
75
|
+
* Returns details of the current session: who is signed in, the project,
|
|
76
|
+
* and when the access and refresh tokens expire.
|
|
72
77
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
78
|
+
* The endpoint is not realm-scoped and answers for signed-out callers too,
|
|
79
|
+
* so check `authenticated` (and `anonymous`) on the result. `null` is
|
|
80
|
+
* returned only when the request is rejected with 401 or 403. Network
|
|
81
|
+
* errors and server errors (5xx) are re-thrown so callers can handle them.
|
|
75
82
|
*/
|
|
76
|
-
get(): Promise<
|
|
83
|
+
get(): Promise<SessionDetails | null>;
|
|
77
84
|
}
|
|
78
85
|
//# sourceMappingURL=session.d.ts.map
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM;IAGhC;;;;;;;;;OASG;IACG,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAqBxE;;;;;;;OAOG;IACG,eAAe,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAkBtD;;;;;;;;;;OAUG;IACG,OAAO,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAoB9C;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B;;;;;;;;OAQG;IACG,GAAG,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CAU5C"}
|
package/dist/session.js
CHANGED
|
@@ -19,6 +19,10 @@ import { OblaxHttpError } from '@oblax/core';
|
|
|
19
19
|
* // Renew before expiry
|
|
20
20
|
* await oblax.auth.session.refresh()
|
|
21
21
|
*
|
|
22
|
+
* // Who is signed in?
|
|
23
|
+
* const details = await oblax.auth.session.get()
|
|
24
|
+
* if (details?.authenticated) console.log(details.user.email)
|
|
25
|
+
*
|
|
22
26
|
* // Log out
|
|
23
27
|
* await oblax.auth.session.destroy()
|
|
24
28
|
* ```
|
|
@@ -117,14 +121,17 @@ export class SessionSubmodule {
|
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
/**
|
|
120
|
-
* Returns the
|
|
124
|
+
* Returns details of the current session: who is signed in, the project,
|
|
125
|
+
* and when the access and refresh tokens expire.
|
|
121
126
|
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
127
|
+
* The endpoint is not realm-scoped and answers for signed-out callers too,
|
|
128
|
+
* so check `authenticated` (and `anonymous`) on the result. `null` is
|
|
129
|
+
* returned only when the request is rejected with 401 or 403. Network
|
|
130
|
+
* errors and server errors (5xx) are re-thrown so callers can handle them.
|
|
124
131
|
*/
|
|
125
132
|
async get() {
|
|
126
133
|
try {
|
|
127
|
-
return await this.ctx.http.get(
|
|
134
|
+
return await this.ctx.http.get('/auth/session');
|
|
128
135
|
}
|
|
129
136
|
catch (err) {
|
|
130
137
|
if (err instanceof OblaxHttpError && (err.status === 401 || err.status === 403)) {
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAI5C
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,gBAAgB;IAC3B,YACmB,GAAiB,EACjB,KAAa;QADb,QAAG,GAAH,GAAG,CAAc;QACjB,UAAK,GAAL,KAAK,CAAQ;IAC7B,CAAC;IAEJ;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAM,CA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,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAA;QACvC,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAiB,eAAe,CAAC,CAAA;QACjE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,cAAc,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,EAAE,CAAC;gBAChF,OAAO,IAAI,CAAA;YACb,CAAC;YACD,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,27 +14,60 @@ export interface SessionTokens {
|
|
|
14
14
|
/** Unix timestamp (seconds) when the access token expires. */
|
|
15
15
|
expiration: number;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Details of the current session, returned by `session.get()`.
|
|
19
|
+
*
|
|
20
|
+
* The endpoint answers for anonymous and signed-out callers too; check
|
|
21
|
+
* `authenticated` (and `anonymous`) rather than relying on an error.
|
|
22
|
+
*/
|
|
23
|
+
export interface SessionDetails {
|
|
24
|
+
/** `true` when a valid, non-anonymous user token was sent. */
|
|
25
|
+
authenticated: boolean;
|
|
26
|
+
/** `true` when the token belongs to an anonymous (guest) session. */
|
|
27
|
+
anonymous: boolean;
|
|
28
|
+
session_id: string;
|
|
29
|
+
user: {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
email: string;
|
|
33
|
+
};
|
|
34
|
+
project: {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
code: string;
|
|
38
|
+
};
|
|
39
|
+
access_token: {
|
|
40
|
+
/** RFC 3339 timestamp, or `null` when no readable access token was sent. */
|
|
41
|
+
expires_at: string | null;
|
|
42
|
+
};
|
|
43
|
+
refresh_token: {
|
|
44
|
+
/** Present when a valid refresh token was sent. */
|
|
45
|
+
id?: string;
|
|
46
|
+
/** RFC 3339 timestamp, or `null` when no valid refresh token was sent. */
|
|
47
|
+
expires_at: string | null;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
17
50
|
export interface CreateSessionParams {
|
|
18
51
|
/** User's email address. */
|
|
19
52
|
email: string;
|
|
20
53
|
/** User's password. */
|
|
21
54
|
password: string;
|
|
22
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* An account as the API returns it. It carries no tokens: the confirmation
|
|
58
|
+
* token only travels in the confirmation mail, and session tokens come from
|
|
59
|
+
* `session.create()`.
|
|
60
|
+
*/
|
|
23
61
|
export interface Account {
|
|
24
62
|
id: string;
|
|
63
|
+
/** The identity person the account belongs to. */
|
|
25
64
|
owner_id: string;
|
|
26
|
-
/** Authentication provider, e.g. `"
|
|
65
|
+
/** Authentication provider, e.g. `"oblax"`. */
|
|
27
66
|
provider: string;
|
|
28
67
|
email: string;
|
|
29
|
-
|
|
30
|
-
refresh_token: string;
|
|
68
|
+
/** Whether the email address was confirmed (from the mail, or by an admin). */
|
|
31
69
|
confirmed: boolean;
|
|
32
70
|
active: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* One-time token sent to the user's email address.
|
|
35
|
-
* Present only on the `create` response; empty string after confirmation.
|
|
36
|
-
*/
|
|
37
|
-
confirmation_token: string;
|
|
38
71
|
}
|
|
39
72
|
export interface CreateAccountParams {
|
|
40
73
|
firstName: string;
|
|
@@ -42,13 +75,18 @@ export interface CreateAccountParams {
|
|
|
42
75
|
email: string;
|
|
43
76
|
password: string;
|
|
44
77
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
78
|
+
* @deprecated The API ignores it, so the SDK doesn't send it: a new account always
|
|
79
|
+
* gets the project's default role (`user` unless an admin changed it with
|
|
80
|
+
* `roles.setDefault`), so sign-up can't pick a role. An app admin
|
|
81
|
+
* changes a person's role afterwards.
|
|
47
82
|
*/
|
|
48
|
-
role
|
|
83
|
+
role?: string;
|
|
49
84
|
}
|
|
50
85
|
export interface ConfirmAccountParams {
|
|
51
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* The token from the link in the confirmation mail the API sends after
|
|
88
|
+
* `accounts.create()`. The app never gets it any other way.
|
|
89
|
+
*/
|
|
52
90
|
confirmationToken: string;
|
|
53
91
|
}
|
|
54
92
|
export interface EnableAccountParams {
|
|
@@ -89,12 +127,48 @@ export interface RealmIdParams {
|
|
|
89
127
|
id: string;
|
|
90
128
|
}
|
|
91
129
|
/** Access level of a role. */
|
|
92
|
-
export type RoleType = '
|
|
130
|
+
export type RoleType = 'admin' | 'manager' | 'user';
|
|
93
131
|
export interface Role {
|
|
94
132
|
id: string;
|
|
95
133
|
name: string;
|
|
96
134
|
type: RoleType;
|
|
97
135
|
realm_id: string;
|
|
136
|
+
/** `true` for the role given to new accounts that don't name one. Omitted when `false`. */
|
|
137
|
+
default?: boolean;
|
|
138
|
+
}
|
|
139
|
+
export interface SetDefaultRoleParams {
|
|
140
|
+
/** ID of the role to change. */
|
|
141
|
+
id: string;
|
|
142
|
+
/** `true` to make this the default role, `false` to unset it. */
|
|
143
|
+
default: boolean;
|
|
144
|
+
}
|
|
145
|
+
/** Kind of authentication event recorded in the auth log. */
|
|
146
|
+
export type AuthLogEvent = 'login_attempt' | 'logout' | 'token_refresh' | 'mfa_challenge' | 'mfa_success' | 'password_reset' | 'password_reset_requested' | 'account_created' | 'account_confirmed' | 'anonymous_session';
|
|
147
|
+
/** One authentication event (sign-in, sign-out, password reset, ...). */
|
|
148
|
+
export interface AuthLog {
|
|
149
|
+
id: string;
|
|
150
|
+
/** ID of the user the event belongs to; empty when unknown (e.g. a failed sign-in). */
|
|
151
|
+
owner_id: string;
|
|
152
|
+
realm: string;
|
|
153
|
+
event: AuthLogEvent;
|
|
154
|
+
status: 'success' | 'failure';
|
|
155
|
+
failure_reason: string;
|
|
156
|
+
ip_address: string;
|
|
157
|
+
browser: string;
|
|
158
|
+
operating_system: string;
|
|
159
|
+
location: string;
|
|
160
|
+
/** What the caller identified with, e.g. the email address. */
|
|
161
|
+
identifier: string;
|
|
162
|
+
_created?: string;
|
|
163
|
+
_modified?: string;
|
|
164
|
+
}
|
|
165
|
+
export interface AuthLogIdParams {
|
|
166
|
+
id: string;
|
|
167
|
+
}
|
|
168
|
+
/** Public key used to verify the project's access tokens (JWTs). */
|
|
169
|
+
export interface PublicKey {
|
|
170
|
+
/** The public key from the project's keyring. */
|
|
171
|
+
public_key: string;
|
|
98
172
|
}
|
|
99
173
|
export interface CreateRoleParams {
|
|
100
174
|
name: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,kFAAkF;IAClF,mBAAmB,EAAE,MAAM,CAAA;IAC3B,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAID,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,kFAAkF;IAClF,mBAAmB,EAAE,MAAM,CAAA;IAC3B,8DAA8D;IAC9D,UAAU,EAAE,MAAM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+1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oblax/auth",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Oblax SDK — auth module (session, realms, roles)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -37,15 +37,16 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@oblax/core": "1.0
|
|
40
|
+
"@oblax/core": "^2.1.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"typescript": "^5.5.0",
|
|
44
|
-
"@oblax/core": "1.0
|
|
44
|
+
"@oblax/core": "2.1.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsc --build tsconfig.json",
|
|
48
48
|
"typecheck": "tsc --build tsconfig.json --dry",
|
|
49
|
+
"test": "tsc --build tsconfig.json && node --test \"test/*.test.ts\"",
|
|
49
50
|
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
50
51
|
}
|
|
51
52
|
}
|