@owlmeans/auth 0.1.18-rc.4 → 0.1.18-rc.40
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/README.md +288 -45
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/auth/SKILL.md +131 -32
- package/agent-meta/skills/auth-protocol/SKILL.md +165 -90
- package/build/allowance/index.d.ts +1 -1
- package/build/allowance/index.d.ts.map +1 -1
- package/build/allowance/index.js +1 -1
- package/build/allowance/index.js.map +1 -1
- package/build/allowance/{model.d.ts → schemas.d.ts} +1 -1
- package/build/allowance/schemas.d.ts.map +1 -0
- package/build/allowance/{model.js → schemas.js} +7 -5
- package/build/allowance/schemas.js.map +1 -0
- package/build/auth/index.d.ts +1 -1
- package/build/auth/index.d.ts.map +1 -1
- package/build/auth/index.js +1 -1
- package/build/auth/index.js.map +1 -1
- package/build/auth/{model.d.ts → schemas.d.ts} +1 -1
- package/build/auth/schemas.d.ts.map +1 -0
- package/build/auth/{model.js → schemas.js} +4 -4
- package/build/auth/schemas.js.map +1 -0
- package/build/consts.d.ts +11 -1
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +12 -2
- package/build/consts.js.map +1 -1
- package/build/entity/index.d.ts +1 -1
- package/build/entity/index.js +1 -1
- package/build/entity/{profile.d.ts → schemas.d.ts} +1 -1
- package/build/entity/schemas.d.ts.map +1 -0
- package/build/entity/{profile.js → schemas.js} +4 -4
- package/build/entity/{profile.js.map → schemas.js.map} +1 -1
- package/build/errors.d.ts +15 -0
- package/build/errors.d.ts.map +1 -1
- package/build/errors.js +19 -0
- package/build/errors.js.map +1 -1
- package/build/helper/types.d.ts +22 -0
- package/build/helper/types.d.ts.map +1 -0
- package/build/helper/types.js +2 -0
- package/build/helper/types.js.map +1 -0
- package/build/helper.d.ts +9 -3
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +30 -17
- package/build/helper.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/permission/index.d.ts +1 -1
- package/build/permission/index.d.ts.map +1 -1
- package/build/permission/index.js +1 -1
- package/build/permission/index.js.map +1 -1
- package/build/permission/{model.d.ts → schemas.d.ts} +1 -1
- package/build/permission/schemas.d.ts.map +1 -0
- package/build/permission/{model.js → schemas.js} +1 -1
- package/build/permission/schemas.js.map +1 -0
- package/build/rely/index.d.ts +1 -1
- package/build/rely/index.d.ts.map +1 -1
- package/build/rely/index.js +1 -1
- package/build/rely/index.js.map +1 -1
- package/build/rely/{model.d.ts → schemas.d.ts} +1 -1
- package/build/rely/schemas.d.ts.map +1 -0
- package/build/rely/{model.js → schemas.js} +1 -1
- package/build/rely/schemas.js.map +1 -0
- package/build/supervisor.d.ts +0 -8
- package/build/supervisor.d.ts.map +1 -1
- package/build/types.d.ts +23 -1
- package/build/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/allowance/index.ts +1 -1
- package/src/allowance/{model.ts → schemas.ts} +6 -4
- package/src/auth/index.ts +1 -1
- package/src/auth/{model.ts → schemas.ts} +3 -3
- package/src/consts.ts +14 -2
- package/src/entity/index.ts +1 -1
- package/src/entity/{profile.ts → schemas.ts} +3 -3
- package/src/errors.ts +22 -1
- package/src/helper/types.ts +22 -0
- package/src/helper.ts +44 -21
- package/src/index.ts +1 -0
- package/src/permission/index.ts +1 -1
- package/src/rely/index.ts +1 -1
- package/src/supervisor.ts +0 -8
- package/src/types.ts +30 -7
- package/tests/errors.spec.ts +19 -0
- package/build/.gitkeep +0 -0
- package/build/allowance/model.d.ts.map +0 -1
- package/build/allowance/model.js.map +0 -1
- package/build/auth/model.d.ts.map +0 -1
- package/build/auth/model.js.map +0 -1
- package/build/entity/profile.d.ts.map +0 -1
- package/build/permission/model.d.ts.map +0 -1
- package/build/permission/model.js.map +0 -1
- package/build/rely/model.d.ts.map +0 -1
- package/build/rely/model.js.map +0 -1
- /package/src/permission/{model.ts → schemas.ts} +0 -0
- /package/src/rely/{model.ts → schemas.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PermissionSetSchema, AttributeSetSchema } from '../permission/
|
|
1
|
+
import { EntitySlugValueSchema, IdValueSchema } from '../consts.js';
|
|
2
|
+
import { PermissionSetSchema, AttributeSetSchema } from '../permission/schemas.js';
|
|
3
3
|
export const ProfileSchema = {
|
|
4
4
|
type: 'object',
|
|
5
5
|
properties: {
|
|
@@ -8,7 +8,7 @@ export const ProfileSchema = {
|
|
|
8
8
|
credential: { type: 'string', nullable: true },
|
|
9
9
|
secret: { type: 'string', nullable: true },
|
|
10
10
|
groups: { type: 'array', items: { type: 'string' }, nullable: true },
|
|
11
|
-
|
|
11
|
+
entitySlug: { ...EntitySlugValueSchema, nullable: true },
|
|
12
12
|
scopes: { type: 'array', items: { type: 'string' } },
|
|
13
13
|
permissions: { type: 'array', items: PermissionSetSchema, nullable: true },
|
|
14
14
|
attributes: { type: 'array', items: AttributeSetSchema, nullable: true },
|
|
@@ -18,4 +18,4 @@ export const ProfileSchema = {
|
|
|
18
18
|
required: ['id', 'name', 'scopes'],
|
|
19
19
|
additionalProperties: false,
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/entity/schemas.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElF,MAAM,CAAC,MAAM,aAAa,GAA4B;IACpD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,aAAa;QACjB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE;QACtD,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC9C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1C,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;QACpE,UAAU,EAAE,EAAC,GAAG,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAC;QACtD,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;QACpD,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1E,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxE,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;QACjD,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;KAClD;IACD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC;IAClC,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
|
package/build/errors.d.ts
CHANGED
|
@@ -3,14 +3,29 @@ export declare class AuthError extends ResilientError {
|
|
|
3
3
|
static typeName: string;
|
|
4
4
|
constructor(message?: string);
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* The request names an authentication method, provider or identity this server does not know — an
|
|
8
|
+
* unregistered plugin type, a sign-in method a gate refuses, a request carrying no organization.
|
|
9
|
+
* That is the caller's request, not a crashed server, so it answers 400 (`httpStatus`, read by
|
|
10
|
+
* `@owlmeans/server-api`). It is outside the authorization family on purpose: a failed credential
|
|
11
|
+
* stays 401 (`AuthorizationError`) and a refused permission 403 (`AuthForbidden`).
|
|
12
|
+
*/
|
|
6
13
|
export declare class AuthUnknown extends AuthError {
|
|
7
14
|
static typeName: string;
|
|
15
|
+
static httpStatus: number;
|
|
8
16
|
constructor(message?: string);
|
|
9
17
|
}
|
|
10
18
|
export declare class AuthManagerError extends AuthError {
|
|
11
19
|
static typeName: string;
|
|
12
20
|
constructor(message?: string);
|
|
13
21
|
}
|
|
22
|
+
/** An authentication authority could not be consulted, so access must fail closed. */
|
|
23
|
+
export declare class AuthUnavailable extends AuthError {
|
|
24
|
+
static typeName: string;
|
|
25
|
+
static httpStatus: number;
|
|
26
|
+
static allowServerErrorStatus: boolean;
|
|
27
|
+
constructor(message?: string);
|
|
28
|
+
}
|
|
14
29
|
export declare class AuthManagerUnsupported extends AuthManagerError {
|
|
15
30
|
static typeName: string;
|
|
16
31
|
constructor(message?: string);
|
package/build/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,qBAAa,SAAU,SAAQ,cAAc;IAC3C,OAAuB,QAAQ,EAAE,MAAM,CAAc;IAErD,YAAY,OAAO,GAAE,MAAgB,EAEpC;CACF;AAED,qBAAa,WAAY,SAAQ,SAAS;IACxC,OAAuB,QAAQ,EAAE,MAAM,CAAiC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,qBAAa,SAAU,SAAQ,cAAc;IAC3C,OAAuB,QAAQ,EAAE,MAAM,CAAc;IAErD,YAAY,OAAO,GAAE,MAAgB,EAEpC;CACF;AAED;;;;;;GAMG;AACH,qBAAa,WAA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,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,aAAc,SAAQ,kBAAkB;IACnD,OAAuB,QAAQ,EAAE,MAAM,CAA4C;IAEnF,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,YAAa,SAAQ,SAAS;IACzC,OAAuB,QAAQ,EAAE,MAAM,CAAiB;IAExD,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAuB,QAAQ,EAAE,MAAM,CAAwC;IAE/E,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF"}
|
package/build/errors.js
CHANGED
|
@@ -5,8 +5,16 @@ export class AuthError extends ResilientError {
|
|
|
5
5
|
super(AuthError.typeName, `auth:${message}`);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* The request names an authentication method, provider or identity this server does not know — an
|
|
10
|
+
* unregistered plugin type, a sign-in method a gate refuses, a request carrying no organization.
|
|
11
|
+
* That is the caller's request, not a crashed server, so it answers 400 (`httpStatus`, read by
|
|
12
|
+
* `@owlmeans/server-api`). It is outside the authorization family on purpose: a failed credential
|
|
13
|
+
* stays 401 (`AuthorizationError`) and a refused permission 403 (`AuthForbidden`).
|
|
14
|
+
*/
|
|
8
15
|
export class AuthUnknown extends AuthError {
|
|
9
16
|
static typeName = `${AuthError.typeName}Unknown`;
|
|
17
|
+
static httpStatus = 400;
|
|
10
18
|
constructor(message = 'error') {
|
|
11
19
|
super(`unknown:${message}`);
|
|
12
20
|
this.type = AuthUnknown.typeName;
|
|
@@ -19,6 +27,16 @@ export class AuthManagerError extends AuthError {
|
|
|
19
27
|
this.type = AuthManagerError.typeName;
|
|
20
28
|
}
|
|
21
29
|
}
|
|
30
|
+
/** An authentication authority could not be consulted, so access must fail closed. */
|
|
31
|
+
export class AuthUnavailable extends AuthError {
|
|
32
|
+
static typeName = `${AuthError.typeName}Unavailable`;
|
|
33
|
+
static httpStatus = 503;
|
|
34
|
+
static allowServerErrorStatus = true;
|
|
35
|
+
constructor(message = 'unavailable') {
|
|
36
|
+
super(`unavailable:${message}`);
|
|
37
|
+
this.type = AuthUnavailable.typeName;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
22
40
|
export class AuthManagerUnsupported extends AuthManagerError {
|
|
23
41
|
static typeName = `${AuthManagerError.typeName}Unsupported`;
|
|
24
42
|
constructor(message = 'error') {
|
|
@@ -92,6 +110,7 @@ export class ProfileConsistencyError extends ProfileError {
|
|
|
92
110
|
ResilientError.registerErrorClass(AuthError);
|
|
93
111
|
ResilientError.registerErrorClass(AuthUnknown);
|
|
94
112
|
ResilientError.registerErrorClass(AuthManagerError);
|
|
113
|
+
ResilientError.registerErrorClass(AuthUnavailable);
|
|
95
114
|
ResilientError.registerErrorClass(AuthManagerUnsupported);
|
|
96
115
|
ResilientError.registerErrorClass(AuthenFailed);
|
|
97
116
|
ResilientError.registerErrorClass(AuthenExists);
|
package/build/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,OAAO,SAAU,SAAQ,cAAc;IACpC,MAAM,CAAU,QAAQ,GAAW,WAAW,CAAA;IAErD,YAAY,OAAO,GAAW,OAAO;QACnC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,OAAO,EAAE,CAAC,CAAA;IAC9C,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,SAAS;IACjC,MAAM,CAAU,QAAQ,GAAW,GAAG,SAAS,CAAC,QAAQ,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,OAAO,SAAU,SAAQ,cAAc;IACpC,MA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,CAAA;AAC5C,cAAc,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;AAC9C,cAAc,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;AACnD,cAAc,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;AAClD,cAAc,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,CAAA;AACzD,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAA;AACrD,cAAc,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;AAClD,cAAc,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAA;AACrD,cAAc,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAA;AACrD,aAAa,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Auth, AuthCredentials, AuthToken, Authorization } from '../types.js';
|
|
2
|
+
/** Checks of the authentication payloads that cross the wire. */
|
|
3
|
+
export interface AuthHelper {
|
|
4
|
+
/** Whether a value satisfies the `Auth` schema. */
|
|
5
|
+
verifyAuth: (auth: Auth) => boolean;
|
|
6
|
+
/** Whether a value satisfies the `AuthCredentials` schema. */
|
|
7
|
+
verifyAuthCredentials: (auth: AuthCredentials) => boolean;
|
|
8
|
+
isAuth: (auth: unknown) => auth is Auth;
|
|
9
|
+
isAuthCredentials: (auth: unknown) => auth is AuthCredentials;
|
|
10
|
+
isAuthToken: (auth: unknown) => auth is AuthToken;
|
|
11
|
+
/**
|
|
12
|
+
* The organization slug carried by an auth payload, tolerating tokens minted before the field
|
|
13
|
+
* was named.
|
|
14
|
+
*
|
|
15
|
+
* Tokens outlive deployments: one signed with the previous release still arrives with the value
|
|
16
|
+
* under `entityId`, and it stays valid until it expires. Everything that reads the organization
|
|
17
|
+
* off a payload goes through here so that window needs no second code path — and so the day the
|
|
18
|
+
* fallback can be deleted is a single-line change rather than an audit.
|
|
19
|
+
*/
|
|
20
|
+
entitySlugOf: (payload?: Partial<Authorization> | null) => string | undefined;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/helper/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAElF,iEAAiE;AACjE,MAAM,WAAW,UAAU;IACzB,mDAAmD;IACnD,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAA;IACnC,8DAA8D;IAC9D,qBAAqB,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,CAAA;IACzD,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,IAAI,IAAI,CAAA;IACvC,iBAAiB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,IAAI,eAAe,CAAA;IAC7D,WAAW,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,IAAI,SAAS,CAAA;IACjD;;;;;;;;OAQG;IACH,YAAY,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,KAAK,MAAM,GAAG,SAAS,CAAA;CAC9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/helper/types.ts"],"names":[],"mappings":""}
|
package/build/helper.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import type { Auth, AuthCredentials, AuthToken } from './types.js';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
import type { Auth, AuthCredentials, AuthToken, Authorization } from './types.js';
|
|
2
|
+
import type { AuthHelper } from './helper/types.js';
|
|
3
|
+
export declare const createAuthHelper: () => AuthHelper;
|
|
4
|
+
export declare const authHelper: AuthHelper;
|
|
5
|
+
/** @deprecated compat:factory-refactor — use `authHelper.isAuth(…)` */
|
|
4
6
|
export declare const isAuth: (auth: unknown) => auth is Auth;
|
|
7
|
+
/** @deprecated compat:factory-refactor — use `authHelper.isAuthCredentials(…)` */
|
|
5
8
|
export declare const isAuthCredentials: (auth: unknown) => auth is AuthCredentials;
|
|
9
|
+
/** @deprecated compat:factory-refactor — use `authHelper.isAuthToken(…)` */
|
|
6
10
|
export declare const isAuthToken: (auth: unknown) => auth is AuthToken;
|
|
11
|
+
/** @deprecated compat:factory-refactor — use `authHelper.entitySlugOf(…)` */
|
|
12
|
+
export declare const entitySlugOf: (payload?: Partial<Authorization> | null) => string | undefined;
|
|
7
13
|
//# sourceMappingURL=helper.d.ts.map
|
package/build/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAIjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,eAAO,MAAM,gBAAgB,QAAO,UAiCnC,CAAA;AAED,eAAO,MAAM,UAAU,YAAqB,CAAA;AAE5C,uEAAuE;AACvE,eAAO,MAAM,MAAM,SAAU,OAAO,KAAG,IAAI,IAAI,IAA+B,CAAA;AAE9E,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,SAAU,OAAO,KAAG,IAAI,IAAI,eAAqD,CAAA;AAE/G,4EAA4E;AAC5E,eAAO,MAAM,WAAW,SAAU,OAAO,KAAG,IAAI,IAAI,SAAyC,CAAA;AAE7F,6EAA6E;AAC7E,eAAO,MAAM,YAAY,aAAc,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,KAAG,MAAM,GAAG,SAC9C,CAAA"}
|
package/build/helper.js
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { Ajv } from 'ajv';
|
|
2
2
|
import formatsPlugin from 'ajv-formats';
|
|
3
|
-
import { AuthCredentialsSchema, AuthSchema } from './allowance/
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
3
|
+
import { AuthCredentialsSchema, AuthSchema } from './allowance/schemas.js';
|
|
4
|
+
export const createAuthHelper = () => {
|
|
5
|
+
const ajv = new Ajv({ strict: false });
|
|
6
|
+
// @TODO There is some serious type mismatch probably because of wrong versions resolution
|
|
7
|
+
formatsPlugin(ajv);
|
|
8
|
+
const verifyAuth = (auth) => {
|
|
9
|
+
const validate = ajv.compile(AuthSchema);
|
|
10
|
+
return validate(auth);
|
|
11
|
+
};
|
|
12
|
+
const verifyAuthCredentials = (auth) => {
|
|
13
|
+
const validate = ajv.compile(AuthCredentialsSchema);
|
|
14
|
+
return validate(auth);
|
|
15
|
+
};
|
|
16
|
+
const isAuth = (auth) => typeof auth === 'object' && auth != null
|
|
17
|
+
&& ("token" in auth) && ("isUser" in auth);
|
|
18
|
+
const isAuthCredentials = (auth) => typeof auth === 'object' && auth != null
|
|
19
|
+
&& ("challenge" in auth) && ("credential" in auth);
|
|
20
|
+
const isAuthToken = (auth) => typeof auth === 'object' && auth != null
|
|
21
|
+
&& ("token" in auth) && typeof auth.token === 'string';
|
|
22
|
+
const entitySlugOf = (payload) => payload?.entitySlug ?? payload?.entityId;
|
|
23
|
+
return { verifyAuth, verifyAuthCredentials, isAuth, isAuthCredentials, isAuthToken, entitySlugOf };
|
|
10
24
|
};
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const
|
|
16
|
-
|
|
17
|
-
export const
|
|
18
|
-
|
|
19
|
-
export const
|
|
20
|
-
&& ("token" in auth) && typeof auth.token === 'string';
|
|
25
|
+
export const authHelper = createAuthHelper();
|
|
26
|
+
/** @deprecated compat:factory-refactor — use `authHelper.isAuth(…)` */
|
|
27
|
+
export const isAuth = (auth) => authHelper.isAuth(auth);
|
|
28
|
+
/** @deprecated compat:factory-refactor — use `authHelper.isAuthCredentials(…)` */
|
|
29
|
+
export const isAuthCredentials = (auth) => authHelper.isAuthCredentials(auth);
|
|
30
|
+
/** @deprecated compat:factory-refactor — use `authHelper.isAuthToken(…)` */
|
|
31
|
+
export const isAuthToken = (auth) => authHelper.isAuthToken(auth);
|
|
32
|
+
/** @deprecated compat:factory-refactor — use `authHelper.entitySlugOf(…)` */
|
|
33
|
+
export const entitySlugOf = (payload) => authHelper.entitySlugOf(payload);
|
|
21
34
|
//# sourceMappingURL=helper.js.map
|
package/build/helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,aAAa,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,aAAa,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAG1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,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AAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,CAAA;AACpG,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAA;AAE5C,uEAAuE;AACvE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAa,EAAgB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAE9E,kFAAkF;AAClF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAa,EAA2B,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;AAE/G,4EAA4E;AAC5E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAa,EAAqB,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;AAE7F,6EAA6E;AAC7E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAuC,EAAsB,EAAE,CAC1F,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA"}
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,mBAAmB,CAAA;AACtC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './schemas.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/permission/index.ts"],"names":[],"mappings":"AACA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/permission/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './schemas.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/permission/index.ts"],"names":[],"mappings":"AACA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/permission/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA"}
|
|
@@ -3,4 +3,4 @@ import { AttributeSet, Capabilties, PermissionSet } from '../types.js';
|
|
|
3
3
|
export declare const CapabiltiesSchema: JSONSchemaType<Capabilties>;
|
|
4
4
|
export declare const PermissionSetSchema: JSONSchemaType<PermissionSet>;
|
|
5
5
|
export declare const AttributeSetSchema: JSONSchemaType<AttributeSet>;
|
|
6
|
-
//# sourceMappingURL=
|
|
6
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/permission/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGtE,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAIzD,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAAC,aAAa,CAU7D,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,YAAY,CAQ3D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/permission/schemas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE1F,MAAM,CAAC,MAAM,iBAAiB,GAAgC;IAC5D,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;IACrE,QAAQ,EAAE,EAAE;CACb,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAkC;IAChE,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE;QACvE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,iBAAiB;QAC9B,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;KACzE;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC;IAClC,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAiC;IAC9D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,gBAAgB;QACvB,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE;KAC3D;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC;IACjC,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
|
package/build/rely/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rely/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rely/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,cAAc,CAAA"}
|
package/build/rely/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './schemas.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/build/rely/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rely/index.ts"],"names":[],"mappings":"AAEA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rely/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/rely/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAAC,SAAS,CAUzD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/rely/schemas.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,mBAAmB,GAA8B;IAC5D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;QACpE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;QACtE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;QACrE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;KACvD;IACD,QAAQ,EAAE,CAAC,OAAO,CAAC;IACnB,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
|
package/build/supervisor.d.ts
CHANGED
|
@@ -15,12 +15,4 @@ export declare const buildSupervisorPayload: (challenge: string, userId: string,
|
|
|
15
15
|
userId: string;
|
|
16
16
|
salt: string;
|
|
17
17
|
};
|
|
18
|
-
/**
|
|
19
|
-
* Shape of the value packed into `AuthCredentials.credential` by the supervisor
|
|
20
|
-
* web plugin: the client `salt` plus the `signature` over `buildSupervisorPayload`.
|
|
21
|
-
*/
|
|
22
|
-
export interface SupervisorCredentialPayload {
|
|
23
|
-
salt: string;
|
|
24
|
-
signature: string;
|
|
25
|
-
}
|
|
26
18
|
//# sourceMappingURL=supervisor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,cACtB,MAAM,UAAU,MAAM,QAAQ,MAAM,KAC9C;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAmC,CAAA
|
|
1
|
+
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,cACtB,MAAM,UAAU,MAAM,QAAQ,MAAM,KAC9C;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAmC,CAAA"}
|
package/build/types.d.ts
CHANGED
|
@@ -32,7 +32,17 @@ export interface ProfilePayload extends Authorization {
|
|
|
32
32
|
groups?: string[];
|
|
33
33
|
}
|
|
34
34
|
export interface Authorization {
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The organization entity's slug — renameable, and the ONLY entity value that travels on the
|
|
37
|
+
* wire: in tokens, in URLs and in request bodies.
|
|
38
|
+
*
|
|
39
|
+
* It is deliberately NOT a database key. An implementation that stores things per organization
|
|
40
|
+
* keeps its own stable `entityId` on its records and resolves this slug to it at the boundary,
|
|
41
|
+
* so a rename costs one registry write instead of a migration of every collection, object name
|
|
42
|
+
* and third-party record that ever referenced the organization. Basic auth knows nothing about
|
|
43
|
+
* that id — see `@owlmeans/auth-common`'s entity resolver for the contract that does.
|
|
44
|
+
*/
|
|
45
|
+
entitySlug?: string;
|
|
36
46
|
scopes: string[];
|
|
37
47
|
permissions?: PermissionSet[];
|
|
38
48
|
attributes?: AttributeSet[];
|
|
@@ -55,6 +65,10 @@ export interface Auth extends AuthPayload {
|
|
|
55
65
|
token: string;
|
|
56
66
|
isUser: boolean;
|
|
57
67
|
createdAt: Date;
|
|
68
|
+
/** Opaque session registry key; it is not an organization identifier. */
|
|
69
|
+
sessionId?: string;
|
|
70
|
+
/** Monotonic authorization revision supplied by the session registry. */
|
|
71
|
+
authorizationVersion?: number;
|
|
58
72
|
}
|
|
59
73
|
export interface PermissionSet {
|
|
60
74
|
scope: string;
|
|
@@ -78,4 +92,12 @@ export interface AllowanceResponse {
|
|
|
78
92
|
export interface AuthToken {
|
|
79
93
|
token: string;
|
|
80
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Shape of the value packed into `AuthCredentials.credential` by the supervisor
|
|
97
|
+
* web plugin: the client `salt` plus the `signature` over `buildSupervisorPayload`.
|
|
98
|
+
*/
|
|
99
|
+
export interface SupervisorCredentialPayload {
|
|
100
|
+
salt: string;
|
|
101
|
+
signature: string;
|
|
102
|
+
}
|
|
81
103
|
//# sourceMappingURL=types.d.ts.map
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CAmBnB;AAED,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,CAAA;IACd;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;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AAM,CAAA;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/auth",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.40",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
25
|
+
"@owlmeans/error": "^0.1.18-rc.38",
|
|
26
26
|
"ajv-formats": "^3.0.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@owlmeans/dep-config": "workspace:*",
|
|
33
|
-
"@types/bun": "^1.
|
|
33
|
+
"@types/bun": "^1.4.2",
|
|
34
34
|
"nodemon": "^3.1.14",
|
|
35
35
|
"typescript": "^7.0.2"
|
|
36
36
|
},
|
package/src/allowance/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './schemas.js'
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { JSONSchemaType } from 'ajv'
|
|
2
2
|
import type { AllowanceRequest, Auth, AuthCredentials, AuthPayload } from '../types.js'
|
|
3
3
|
import {
|
|
4
|
-
AuthRoleSchema,
|
|
4
|
+
AuthRoleSchema, EntitySlugValueSchema, GroupValueSchema, IdValueSchema, DateSchema,
|
|
5
5
|
ScopeValueSchema, TypeNameSchema
|
|
6
6
|
} from '../consts.js'
|
|
7
|
-
import { AuthPayloadSchema } from '../auth/
|
|
8
|
-
import { AttributeSetSchema, PermissionSetSchema } from '../permission/
|
|
7
|
+
import { AuthPayloadSchema } from '../auth/schemas.js'
|
|
8
|
+
import { AttributeSetSchema, PermissionSetSchema } from '../permission/schemas.js'
|
|
9
9
|
|
|
10
10
|
export const PartialAuthPayloadSchema: JSONSchemaType<Omit<Partial<AuthPayload>, "type">> = {
|
|
11
11
|
type: 'object',
|
|
@@ -16,7 +16,7 @@ export const PartialAuthPayloadSchema: JSONSchemaType<Omit<Partial<AuthPayload>,
|
|
|
16
16
|
profileId: { ...IdValueSchema, nullable: true },
|
|
17
17
|
expiresAt: { ...DateSchema, nullable: true },
|
|
18
18
|
groups: { type: 'array', items: GroupValueSchema, nullable: true },
|
|
19
|
-
|
|
19
|
+
entitySlug: { ...EntitySlugValueSchema, nullable: true },
|
|
20
20
|
scopes: { type: 'array', items: ScopeValueSchema, nullable: true },
|
|
21
21
|
permissions: { type: 'array', nullable: true, items: PermissionSetSchema },
|
|
22
22
|
attributes: { type: 'array', nullable: true, items: AttributeSetSchema },
|
|
@@ -58,6 +58,8 @@ export const AuthSchema: JSONSchemaType<Auth> = {
|
|
|
58
58
|
token: { type: 'string', minLength: 32, maxLength: 1024 },
|
|
59
59
|
isUser: { type: 'boolean' },
|
|
60
60
|
createdAt: DateSchema,
|
|
61
|
+
sessionId: { type: 'string', minLength: 16, maxLength: 128, nullable: true },
|
|
62
|
+
authorizationVersion: { type: 'integer', minimum: 1, nullable: true },
|
|
61
63
|
expiresAt: { ...DateSchema, nullable: true },
|
|
62
64
|
...AuthPayloadSchema.properties,
|
|
63
65
|
},
|
package/src/auth/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './schemas.js'
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { JSONSchemaType } from 'ajv'
|
|
2
2
|
import type { AuthPayload, AuthToken, Authorization, ProfilePayload } from '../types.js'
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
EntitySlugValueSchema, EnumValueSchema, GroupValueSchema, IdValueSchema, DateSchema, ScopeValueSchema,
|
|
5
5
|
TypeNameSchema
|
|
6
6
|
} from '../consts.js'
|
|
7
|
-
import { AttributeSetSchema, PermissionSetSchema } from '../permission/
|
|
7
|
+
import { AttributeSetSchema, PermissionSetSchema } from '../permission/schemas.js'
|
|
8
8
|
|
|
9
9
|
export const AuthorizationSchema: JSONSchemaType<Authorization> = {
|
|
10
10
|
type: 'object',
|
|
11
11
|
properties: {
|
|
12
|
-
|
|
12
|
+
entitySlug: { ...EntitySlugValueSchema, nullable: true },
|
|
13
13
|
scopes: { type: 'array', items: ScopeValueSchema },
|
|
14
14
|
permissions: { type: 'array', nullable: true, items: PermissionSetSchema },
|
|
15
15
|
attributes: { type: 'array', nullable: true, items: AttributeSetSchema },
|
package/src/consts.ts
CHANGED
|
@@ -98,7 +98,10 @@ export const ResourceValueSchema: JSONSchemaType<string> = { type: 'string', min
|
|
|
98
98
|
|
|
99
99
|
export const AttributeValueSchema: JSONSchemaType<string> = { type: 'string', minLength: 8, maxLength: 128 }
|
|
100
100
|
|
|
101
|
-
export const
|
|
101
|
+
export const EntitySlugValueSchema: JSONSchemaType<string> = { type: 'string', minLength: 3, maxLength: 256 }
|
|
102
|
+
|
|
103
|
+
/** @deprecated The organization value on the wire is a slug — use {@link EntitySlugValueSchema}. */
|
|
104
|
+
export const EntityValueSchema: JSONSchemaType<string> = EntitySlugValueSchema
|
|
102
105
|
|
|
103
106
|
export const GroupValueSchema: JSONSchemaType<string> = { type: 'string', minLength: 1, maxLength: 128 }
|
|
104
107
|
|
|
@@ -115,11 +118,20 @@ export const AuthRoleSchema: JSONSchemaType<AuthRole> = { type: 'string', enum:
|
|
|
115
118
|
export const DISPATCHER = 'dispatcher'
|
|
116
119
|
export const DISPATCHER_AUTHEN = `${DISPATCHER}:authentication`
|
|
117
120
|
|
|
121
|
+
/**
|
|
122
|
+
* The login window opened one level up by an application that cannot complete the flow where it is.
|
|
123
|
+
*
|
|
124
|
+
* A separate entrypoint from {@link DISPATCHER} because it is never a `redirect_uri` — the provider
|
|
125
|
+
* always returns to the dispatcher, whatever page opened the window — and because a logout has to
|
|
126
|
+
* run somewhere that does not start the authorization machine.
|
|
127
|
+
*/
|
|
128
|
+
export const DISPATCHER_SURROGATE = `${DISPATCHER}:surrogate`
|
|
129
|
+
|
|
118
130
|
export const AUTHEN_RELY = `${AUTHEN}-rely`
|
|
119
131
|
|
|
120
132
|
export const AUTH_HEADER = 'authorization'
|
|
121
133
|
export const AUTH_QUERY = 'token'
|
|
122
|
-
export const ENTITY_QUERY = '
|
|
134
|
+
export const ENTITY_QUERY = 'entitySlug'
|
|
123
135
|
export const PROFILE_QUERY = 'profile'
|
|
124
136
|
|
|
125
137
|
export const MOD_RECAPTCHA = '_external:re-captcha'
|
package/src/entity/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './schemas.js'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import type { JSONSchemaType } from 'ajv'
|
|
3
3
|
import type { Profile } from '../types.js'
|
|
4
|
-
import {
|
|
5
|
-
import { PermissionSetSchema, AttributeSetSchema } from '../permission/
|
|
4
|
+
import { EntitySlugValueSchema, IdValueSchema } from '../consts.js'
|
|
5
|
+
import { PermissionSetSchema, AttributeSetSchema } from '../permission/schemas.js'
|
|
6
6
|
|
|
7
7
|
export const ProfileSchema: JSONSchemaType<Profile> = {
|
|
8
8
|
type: 'object',
|
|
@@ -12,7 +12,7 @@ export const ProfileSchema: JSONSchemaType<Profile> = {
|
|
|
12
12
|
credential: { type: 'string', nullable: true },
|
|
13
13
|
secret: { type: 'string', nullable: true },
|
|
14
14
|
groups: { type: 'array', items: { type: 'string' }, nullable: true },
|
|
15
|
-
|
|
15
|
+
entitySlug: {...EntitySlugValueSchema, nullable: true},
|
|
16
16
|
scopes: { type: 'array', items: { type: 'string' } },
|
|
17
17
|
permissions: { type: 'array', items: PermissionSetSchema, nullable: true },
|
|
18
18
|
attributes: { type: 'array', items: AttributeSetSchema, nullable: true },
|