@owlmeans/auth 0.1.18-rc.9 → 0.1.19-rc.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/README.md +289 -45
- package/agent-meta/manifest.json +3 -3
- package/agent-meta/skills/auth/SKILL.md +29 -23
- package/agent-meta/skills/auth-protocol/SKILL.md +111 -91
- 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} +5 -3
- 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} +2 -2
- package/build/auth/schemas.js.map +1 -0
- package/build/consts.d.ts +5 -0
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +5 -0
- 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} +2 -2
- 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 +7 -11
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +30 -27
- 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 +12 -0
- package/build/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/allowance/index.ts +1 -1
- package/src/allowance/{model.ts → schemas.ts} +4 -2
- package/src/auth/index.ts +1 -1
- package/src/auth/{model.ts → schemas.ts} +1 -1
- package/src/consts.ts +6 -0
- package/src/entity/index.ts +1 -1
- package/src/entity/{profile.ts → schemas.ts} +1 -1
- package/src/errors.ts +22 -1
- package/src/helper/types.ts +22 -0
- package/src/helper.ts +44 -33
- 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 +13 -0
- package/tests/errors.spec.ts +19 -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
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,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;;;;;;GAMG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IACjC,MAAM,CAAU,QAAQ,GAAW,GAAG,SAAS,CAAC,QAAQ,SAAS,CAAA;IACjE,MAAM,CAAC,UAAU,GAAG,GAAG,CAAA;IAE9B,YAAY,OAAO,GAAW,OAAO;QACnC,KAAK,CAAC,WAAW,OAA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AAc,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,17 +1,13 @@
|
|
|
1
1
|
import type { Auth, AuthCredentials, AuthToken, Authorization } from './types.js';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
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;
|
|
7
|
-
/**
|
|
8
|
-
* The organization slug carried by an auth payload, tolerating tokens minted before the field
|
|
9
|
-
* was named.
|
|
10
|
-
*
|
|
11
|
-
* Tokens outlive deployments: one signed with the previous release still arrives with the value
|
|
12
|
-
* under `entityId`, and it stays valid until it expires. Everything that reads the organization
|
|
13
|
-
* off a payload goes through here so that window needs no second code path — and so the day the
|
|
14
|
-
* fallback can be deleted is a single-line change rather than an audit.
|
|
15
|
-
*/
|
|
11
|
+
/** @deprecated compat:factory-refactor — use `authHelper.entitySlugOf(…)` */
|
|
16
12
|
export declare const entitySlugOf: (payload?: Partial<Authorization> | null) => string | undefined;
|
|
17
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,aAAa,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,31 +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';
|
|
21
|
-
/**
|
|
22
|
-
* The organization slug carried by an auth payload, tolerating tokens minted before the field
|
|
23
|
-
* was named.
|
|
24
|
-
*
|
|
25
|
-
* Tokens outlive deployments: one signed with the previous release still arrives with the value
|
|
26
|
-
* under `entityId`, and it stays valid until it expires. Everything that reads the organization
|
|
27
|
-
* off a payload goes through here so that window needs no second code path — and so the day the
|
|
28
|
-
* fallback can be deleted is a single-line change rather than an audit.
|
|
29
|
-
*/
|
|
30
|
-
export const entitySlugOf = (payload) => payload?.entitySlug ?? payload?.entityId;
|
|
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);
|
|
31
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/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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
|
@@ -65,6 +65,10 @@ export interface Auth extends AuthPayload {
|
|
|
65
65
|
token: string;
|
|
66
66
|
isUser: boolean;
|
|
67
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;
|
|
68
72
|
}
|
|
69
73
|
export interface PermissionSet {
|
|
70
74
|
scope: string;
|
|
@@ -88,4 +92,12 @@ export interface AllowanceResponse {
|
|
|
88
92
|
export interface AuthToken {
|
|
89
93
|
token: string;
|
|
90
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
|
+
}
|
|
91
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;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,IAAI,CAAA;CAYjB;AAED,MAAM,WAAW,KAAM,SAAQ,aAAa;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAUlB;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;OASG;IACH,UAAU,CAAC,EA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,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@owlmeans/error": "^0.1.18
|
|
25
|
+
"@owlmeans/error": "^0.1.18",
|
|
26
26
|
"ajv-formats": "^3.0.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"ajv": "*"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@owlmeans/dep-config": "
|
|
33
|
-
"@types/bun": "^1.4.
|
|
32
|
+
"@owlmeans/dep-config": "^0.1.18",
|
|
33
|
+
"@types/bun": "^1.4.4",
|
|
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'
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
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',
|
|
@@ -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'
|
|
@@ -4,7 +4,7 @@ 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',
|
package/src/consts.ts
CHANGED
|
@@ -137,5 +137,11 @@ export const PROFILE_QUERY = 'profile'
|
|
|
137
137
|
export const MOD_RECAPTCHA = '_external:re-captcha'
|
|
138
138
|
export const CMOD_RECAPTCHA = `_client-${MOD_RECAPTCHA.slice(1)}`
|
|
139
139
|
|
|
140
|
+
/**
|
|
141
|
+
* The guard of a route a reCAPTCHA-proven guest may call once: `Authorization: RE-CAPTCHA <token>`,
|
|
142
|
+
* the token the auth manager's reCAPTCHA plugin issued (`makeReCaptchaGuard` in server-auth).
|
|
143
|
+
*/
|
|
144
|
+
export const RECAPTCHA_GUARD = 'guard:re-captcha'
|
|
145
|
+
|
|
140
146
|
export const GUEST_ID = '__guest'
|
|
141
147
|
export const RELY_3RD = 'rely'
|
package/src/entity/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './schemas.js'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { JSONSchemaType } from 'ajv'
|
|
3
3
|
import type { Profile } from '../types.js'
|
|
4
4
|
import { EntitySlugValueSchema, IdValueSchema } from '../consts.js'
|
|
5
|
-
import { PermissionSetSchema, AttributeSetSchema } from '../permission/
|
|
5
|
+
import { PermissionSetSchema, AttributeSetSchema } from '../permission/schemas.js'
|
|
6
6
|
|
|
7
7
|
export const ProfileSchema: JSONSchemaType<Profile> = {
|
|
8
8
|
type: 'object',
|
package/src/errors.ts
CHANGED
|
@@ -9,9 +9,17 @@ export class AuthError extends ResilientError {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* The request names an authentication method, provider or identity this server does not know — an
|
|
14
|
+
* unregistered plugin type, a sign-in method a gate refuses, a request carrying no organization.
|
|
15
|
+
* That is the caller's request, not a crashed server, so it answers 400 (`httpStatus`, read by
|
|
16
|
+
* `@owlmeans/server-api`). It is outside the authorization family on purpose: a failed credential
|
|
17
|
+
* stays 401 (`AuthorizationError`) and a refused permission 403 (`AuthForbidden`).
|
|
18
|
+
*/
|
|
12
19
|
export class AuthUnknown extends AuthError {
|
|
13
20
|
public static override typeName: string = `${AuthError.typeName}Unknown`
|
|
14
|
-
|
|
21
|
+
public static httpStatus = 400
|
|
22
|
+
|
|
15
23
|
constructor(message: string = 'error') {
|
|
16
24
|
super(`unknown:${message}`)
|
|
17
25
|
this.type = AuthUnknown.typeName
|
|
@@ -27,6 +35,18 @@ export class AuthManagerError extends AuthError {
|
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
37
|
|
|
38
|
+
/** An authentication authority could not be consulted, so access must fail closed. */
|
|
39
|
+
export class AuthUnavailable extends AuthError {
|
|
40
|
+
public static override typeName: string = `${AuthError.typeName}Unavailable`
|
|
41
|
+
public static httpStatus = 503
|
|
42
|
+
public static allowServerErrorStatus = true
|
|
43
|
+
|
|
44
|
+
constructor(message: string = 'unavailable') {
|
|
45
|
+
super(`unavailable:${message}`)
|
|
46
|
+
this.type = AuthUnavailable.typeName
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
30
50
|
export class AuthManagerUnsupported extends AuthManagerError {
|
|
31
51
|
public static override typeName: string = `${AuthManagerError.typeName}Unsupported`
|
|
32
52
|
|
|
@@ -120,6 +140,7 @@ export class ProfileConsistencyError extends ProfileError {
|
|
|
120
140
|
ResilientError.registerErrorClass(AuthError)
|
|
121
141
|
ResilientError.registerErrorClass(AuthUnknown)
|
|
122
142
|
ResilientError.registerErrorClass(AuthManagerError)
|
|
143
|
+
ResilientError.registerErrorClass(AuthUnavailable)
|
|
123
144
|
ResilientError.registerErrorClass(AuthManagerUnsupported)
|
|
124
145
|
ResilientError.registerErrorClass(AuthenFailed)
|
|
125
146
|
ResilientError.registerErrorClass(AuthenExists)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Auth, AuthCredentials, AuthToken, Authorization } from '../types.js'
|
|
2
|
+
|
|
3
|
+
/** Checks of the authentication payloads that cross the wire. */
|
|
4
|
+
export interface AuthHelper {
|
|
5
|
+
/** Whether a value satisfies the `Auth` schema. */
|
|
6
|
+
verifyAuth: (auth: Auth) => boolean
|
|
7
|
+
/** Whether a value satisfies the `AuthCredentials` schema. */
|
|
8
|
+
verifyAuthCredentials: (auth: AuthCredentials) => boolean
|
|
9
|
+
isAuth: (auth: unknown) => auth is Auth
|
|
10
|
+
isAuthCredentials: (auth: unknown) => auth is AuthCredentials
|
|
11
|
+
isAuthToken: (auth: unknown) => auth is AuthToken
|
|
12
|
+
/**
|
|
13
|
+
* The organization slug carried by an auth payload, tolerating tokens minted before the field
|
|
14
|
+
* was named.
|
|
15
|
+
*
|
|
16
|
+
* Tokens outlive deployments: one signed with the previous release still arrives with the value
|
|
17
|
+
* under `entityId`, and it stays valid until it expires. Everything that reads the organization
|
|
18
|
+
* off a payload goes through here so that window needs no second code path — and so the day the
|
|
19
|
+
* fallback can be deleted is a single-line change rather than an audit.
|
|
20
|
+
*/
|
|
21
|
+
entitySlugOf: (payload?: Partial<Authorization> | null) => string | undefined
|
|
22
|
+
}
|