@oblax/auth 1.0.0 → 2.0.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.
@@ -56,15 +56,17 @@ export declare class AccountsSubmodule {
56
56
  */
57
57
  enable(params: EnableAccountParams): Promise<boolean>;
58
58
  /**
59
- * Sends a password-reset link to the given email address.
59
+ * Starts a password reset for the given email address: the backend mails
60
+ * the account a link carrying the reset token. The link and the token are
61
+ * never returned to the caller; the API answers 204 No Content, also when
62
+ * no account has that email, so the answer doesn't tell whether one exists.
60
63
  *
61
- * @returns The reset link URL (useful in server-side flows where the link
62
- * is delivered by the calling service rather than by the backend).
64
+ * @returns Nothing; resolves once the request is accepted.
63
65
  */
64
- requestPasswordReset(params: RequestPasswordResetParams): Promise<string>;
66
+ requestPasswordReset(params: RequestPasswordResetParams): Promise<void>;
65
67
  /**
66
68
  * Sets a new password using the token from a password-reset email.
67
- * Call `requestPasswordReset` first to obtain the token.
69
+ * Call `requestPasswordReset` first; the token arrives in the email it sends.
68
70
  */
69
71
  resetPassword(params: ResetPasswordParams): Promise<void>;
70
72
  }
@@ -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;;;;;;OAMG;IACG,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAU3D;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,oBAAoB,GA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package/dist/accounts.js CHANGED
@@ -73,10 +73,12 @@ export class AccountsSubmodule {
73
73
  });
74
74
  }
75
75
  /**
76
- * Sends a password-reset link to the given email address.
76
+ * Starts a password reset for the given email address: the backend mails
77
+ * the account a link carrying the reset token. The link and the token are
78
+ * never returned to the caller; the API answers 204 No Content, also when
79
+ * no account has that email, so the answer doesn't tell whether one exists.
77
80
  *
78
- * @returns The reset link URL (useful in server-side flows where the link
79
- * is delivered by the calling service rather than by the backend).
81
+ * @returns Nothing; resolves once the request is accepted.
80
82
  */
81
83
  async requestPasswordReset(params) {
82
84
  return this.ctx.http.post('/auth/accounts/reset-password-link', {
@@ -85,7 +87,7 @@ export class AccountsSubmodule {
85
87
  }
86
88
  /**
87
89
  * Sets a new password using the token from a password-reset email.
88
- * Call `requestPasswordReset` first to obtain the token.
90
+ * Call `requestPasswordReset` first; the token arrives in the email it sends.
89
91
  */
90
92
  async resetPassword(params) {
91
93
  return this.ctx.http.put('/auth/accounts/reset-password', {
@@ -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;;;;;;OAMG;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;YAC3B,IAAI,EAAQ,MAAM,CAAC,IAAI;SACxB,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,MAA4B;QACxC,OA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
@@ -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 four sub-modules:
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
@@ -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;AAE3C;;GAEG;AACH,M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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 four sub-modules:
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,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,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 type { SessionTokens, CreateSessionParams, Account, CreateAccountParams, ConfirmAccountParams, EnableAccountParams, RequestPasswordResetParams, ResetPasswordParams, Realm, ArchivedRealm, CreateRealmParams, UpdateRealmParams, RealmIdParams, RoleType, Role, CreateRoleParams, UpdateRoleParams, RoleIdParams, } from './types.js';
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
  *
@@ -41,6 +43,10 @@ export type { SessionTokens, CreateSessionParams, Account, CreateAccountParams,
41
43
  * // Realm & role management (admin)
42
44
  * const realms = await oblax.auth.realms.list()
43
45
  * const roles = await oblax.auth.roles.list()
46
+ *
47
+ * // Auth log and token verification key (admin)
48
+ * const logs = await oblax.auth.logs.list()
49
+ * const { public_key } = await oblax.auth.keys.getPublic()
44
50
  * ```
45
51
  */
46
52
  export declare function Auth(config: AuthConfig): OblaxModulePlugin<'auth', AuthModule>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/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,mBAAmB,EAEnB,OAAO,EACP,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EAEnB,KAAK,EACL,aAAa,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;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
  *
@@ -37,6 +39,10 @@ export { RolesSubmodule } from './roles.js';
37
39
  * // Realm & role management (admin)
38
40
  * const realms = await oblax.auth.realms.list()
39
41
  * const roles = await oblax.auth.roles.list()
42
+ *
43
+ * // Auth log and token verification key (admin)
44
+ * const logs = await oblax.auth.logs.list()
45
+ * const { public_key } = await oblax.auth.keys.getPublic()
40
46
  * ```
41
47
  */
42
48
  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;AA2B3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;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"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;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
@@ -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,22 @@
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. Requires admin privileges.
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 declare class LogsSubmodule {
15
+ private readonly ctx;
16
+ constructor(ctx: OblaxContext);
17
+ /** Returns all auth log entries. */
18
+ list(): Promise<AuthLog[]>;
19
+ /** Fetches a single auth log entry by ID. */
20
+ get(params: AuthLogIdParams): Promise<AuthLog>;
21
+ }
22
+ //# 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;;;;;;;;;;GAUG;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,25 @@
1
+ /**
2
+ * Reads the authentication log: sign-ins, sign-outs, token refreshes,
3
+ * password resets and account events. Requires admin privileges.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * const logs = await oblax.auth.logs.list()
8
+ * const failed = logs.filter((l) => l.status === 'failure')
9
+ * const one = await oblax.auth.logs.get({ id: logs[0].id })
10
+ * ```
11
+ */
12
+ export class LogsSubmodule {
13
+ constructor(ctx) {
14
+ this.ctx = ctx;
15
+ }
16
+ /** Returns all auth log entries. */
17
+ async list() {
18
+ return this.ctx.http.get('/auth/logs');
19
+ }
20
+ /** Fetches a single auth log entry by ID. */
21
+ async get(params) {
22
+ return this.ctx.http.get(`/auth/logs/${params.id}`);
23
+ }
24
+ }
25
+ //# sourceMappingURL=logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.js","sourceRoot":"","sources":["../src/logs.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;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 (`ADMIN`, `MANAGER`, or `USER`) within a realm
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: 'MANAGER',
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: 'MANAGER', realmId: 'realm-id' })
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
  }
@@ -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;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,2CAA2C;IACrC,IAAI,IAAI,OAAO,CAAC,IAAI,EA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I,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 (`ADMIN`, `MANAGER`, or `USER`) within a realm
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: 'MANAGER',
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: 'MANAGER', realmId: 'realm-id' })
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":"AAQA;;;;;;;;;;;;;;;;;;;;;GAqB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C,CAAA;IACJ,CAAC;IAED,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 active session, or `null` when the user is not authenticated.
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
- * Only 401 and 403 responses are treated as "no session". Network errors
74
- * and server errors (5xx) are re-thrown so callers can handle them.
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<SessionTokens | null>;
83
+ get(): Promise<SessionDetails | null>;
77
84
  }
78
85
  //# sourceMappingURL=session.d.ts.map
@@ -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;A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;;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 active session, or `null` when the user is not authenticated.
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
- * Only 401 and 403 responses are treated as "no session". Network errors
123
- * and server errors (5xx) are re-thrown so callers can handle them.
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(`/auth/session/${this.realm}`);
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)) {
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAI5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,gBAAgB;IAC3B,YACmB,GAAiB,EACjB,KAAa;QADb,QAAG,GAAH,GAAG,CAAc;QAC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AG,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,6 +14,39 @@ 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;
@@ -89,12 +122,48 @@ export interface RealmIdParams {
89
122
  id: string;
90
123
  }
91
124
  /** Access level of a role. */
92
- export type RoleType = 'ADMIN' | 'MANAGER' | 'USER';
125
+ export type RoleType = 'admin' | 'manager' | 'user';
93
126
  export interface Role {
94
127
  id: string;
95
128
  name: string;
96
129
  type: RoleType;
97
130
  realm_id: string;
131
+ /** `true` for the role given to new accounts that don't name one. Omitted when `false`. */
132
+ default?: boolean;
133
+ }
134
+ export interface SetDefaultRoleParams {
135
+ /** ID of the role to change. */
136
+ id: string;
137
+ /** `true` to make this the default role, `false` to unset it. */
138
+ default: boolean;
139
+ }
140
+ /** Kind of authentication event recorded in the auth log. */
141
+ export type AuthLogEvent = 'login_attempt' | 'logout' | 'token_refresh' | 'mfa_challenge' | 'mfa_success' | 'password_reset' | 'password_reset_requested' | 'account_created' | 'account_confirmed' | 'anonymous_session';
142
+ /** One authentication event (sign-in, sign-out, password reset, ...). */
143
+ export interface AuthLog {
144
+ id: string;
145
+ /** ID of the user the event belongs to; empty when unknown (e.g. a failed sign-in). */
146
+ owner_id: string;
147
+ realm: string;
148
+ event: AuthLogEvent;
149
+ status: 'success' | 'failure';
150
+ failure_reason: string;
151
+ ip_address: string;
152
+ browser: string;
153
+ operating_system: string;
154
+ location: string;
155
+ /** What the caller identified with, e.g. the email address. */
156
+ identifier: string;
157
+ _created?: string;
158
+ _modified?: string;
159
+ }
160
+ export interface AuthLogIdParams {
161
+ id: string;
162
+ }
163
+ /** Public key used to verify the project's access tokens (JWTs). */
164
+ export interface PublicKey {
165
+ /** The public key from the project's keyring. */
166
+ public_key: string;
98
167
  }
99
168
  export interface CreateRoleParams {
100
169
  name: string;
@@ -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,UAAU,EAAE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M,EAAE,SAAS,GAAG,SAAS,CAAA;IAC7B,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;CACX;AAID,oEAAoE;AACpE,MAAM,WAAW,SAAS;IACxB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,CAAA;IACd,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,CAAA;IACd,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;CACX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oblax/auth",
3
- "version": "1.0.0",
3
+ "version": "2.0.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.0"
40
+ "@oblax/core": "^2.0.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "typescript": "^5.5.0",
44
- "@oblax/core": "1.0.0"
44
+ "@oblax/core": "2.0.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
  }