@owlmeans/server-auth 0.1.1 → 0.1.3
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/LICENSE +1 -1
- package/README.md +33 -454
- package/build/actions/service.d.ts +2 -2
- package/build/actions/service.d.ts.map +1 -1
- package/build/actions/service.js.map +1 -1
- package/build/manager/actions/manager.d.ts +4 -4
- package/build/manager/actions/manager.d.ts.map +1 -1
- package/build/manager/actions/manager.js.map +1 -1
- package/build/manager/exports.d.ts +4 -4
- package/build/manager/exports.d.ts.map +1 -1
- package/build/manager/exports.js +2 -2
- package/build/manager/exports.js.map +1 -1
- package/build/manager/main.js +1 -1
- package/build/manager/main.js.map +1 -1
- package/build/manager/model.js +2 -2
- package/build/manager/model.js.map +1 -1
- package/build/manager/modules.d.ts +1 -1
- package/build/manager/modules.d.ts.map +1 -1
- package/build/manager/modules.js +3 -3
- package/build/manager/modules.js.map +1 -1
- package/build/manager/plugins/re-captcha.js +3 -3
- package/build/manager/plugins/re-captcha.js.map +1 -1
- package/build/manager/plugins/types.d.ts +1 -1
- package/build/manager/plugins/types.d.ts.map +1 -1
- package/build/manager/plugins/utils.d.ts +1 -1
- package/build/manager/plugins/utils.d.ts.map +1 -1
- package/build/manager/plugins/utils.js +2 -2
- package/build/manager/plugins/utils.js.map +1 -1
- package/build/manager/types.d.ts +1 -1
- package/build/manager/types.d.ts.map +1 -1
- package/build/modules.d.ts +2 -2
- package/build/modules.d.ts.map +1 -1
- package/build/modules.js +2 -2
- package/build/modules.js.map +1 -1
- package/build/types.d.ts +1 -1
- package/build/types.d.ts.map +1 -1
- package/package.json +31 -26
- package/src/actions/service.ts +2 -2
- package/src/manager/actions/manager.ts +4 -4
- package/src/manager/exports.ts +4 -4
- package/src/manager/main.ts +1 -1
- package/src/manager/model.ts +2 -2
- package/src/manager/modules.ts +3 -3
- package/src/manager/plugins/re-captcha.ts +4 -4
- package/src/manager/plugins/types.ts +1 -1
- package/src/manager/plugins/utils.ts +2 -2
- package/src/manager/rely.ts +1 -1
- package/src/manager/types.ts +1 -1
- package/src/modules.ts +5 -5
- package/src/service.ts +1 -1
- package/src/types.ts +1 -1
- package/tests/context.ts +59 -0
- package/tests/service.spec.ts +174 -0
- package/tests/tsconfig.json +12 -0
- package/tsconfig.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/manager/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAQ5C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAA8B,EAAa,EAAE;IACzE,MAAM,KAAK,GAAG,CAAC,OAAgB,EAAuB,EAAE,CACtD,OAAO,CAAC,QAAQ,CAAsB,UAAU,CAAC,CAAA;IAEnD,MAAM,KAAK,GAAc;QACvB,IAAI,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;YACpB,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/manager/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,YA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,CAAC,CAAA;YAC1F,UAAU,CAAC,SAAS,GAAG,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;YAEvD,UAAU,CAAC,UAAU,GAAG,WAAW,CAAC,EAAE,CAAA;YAEtC,OAAO;gBACL,KAAK,EAAE,MAAM,iBAAiB,CAAkB,UAAU,CAAC,IAAI,CAAC;qBAC7D,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC;qBAClC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC;aACrC,CAAA;QACH,CAAC;QAED,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;YACzB,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QACzD,CAAC;KACF,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const modules: import("@owlmeans/
|
|
1
|
+
export declare const modules: import("@owlmeans/entrypoint").CommonEntrypoint[];
|
|
2
2
|
//# sourceMappingURL=modules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../src/manager/modules.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../src/manager/modules.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,OAAO,mDAAO,CAAA"}
|
package/build/manager/modules.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT, AUTHEN_RELY, MOD_RECAPTCHA } from '@owlmeans/auth';
|
|
2
2
|
import { modules as list } from '@owlmeans/auth-common';
|
|
3
3
|
import { modules as apiConfig } from '@owlmeans/api-config-server';
|
|
4
|
-
import { elevate, guard } from '@owlmeans/server-
|
|
4
|
+
import { elevate, guard } from '@owlmeans/server-entrypoint';
|
|
5
5
|
import * as actions from './actions/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { entrypoint } from '@owlmeans/client-entrypoint';
|
|
7
7
|
import { backend, route, RouteMethod } from '@owlmeans/route';
|
|
8
8
|
import { handleIntermediate } from '@owlmeans/server-api';
|
|
9
9
|
import { DEFAULT_RELY } from './consts.js';
|
|
@@ -13,7 +13,7 @@ elevate(list, AUTHEN_AUTHEN, actions.authenticate);
|
|
|
13
13
|
elevate(list, AUTHEN_RELY, actions.rely, guard(DEFAULT_RELY));
|
|
14
14
|
export const modules = list;
|
|
15
15
|
list.push(...apiConfig);
|
|
16
|
-
list.push(
|
|
16
|
+
list.push(entrypoint(route(MOD_RECAPTCHA, '/api/siteverify', backend({
|
|
17
17
|
host: 'https://www.google.com',
|
|
18
18
|
base: 'recaptcha',
|
|
19
19
|
secure: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/manager/modules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC/F,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/manager/modules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC/F,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE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uthRole } from '@owlmeans/auth';
|
|
2
2
|
import { PLUGINS } from '@owlmeans/config';
|
|
3
3
|
import { PluginMissconfigured } from '@owlmeans/config';
|
|
4
|
-
import {
|
|
4
|
+
import { EntrypointOutcome } from '@owlmeans/entrypoint';
|
|
5
5
|
import { base64 } from '@scure/base';
|
|
6
6
|
import { randomBytes } from '@noble/hashes/utils';
|
|
7
7
|
import { assertType } from './utils.js';
|
|
@@ -19,7 +19,7 @@ export const reCaptcha = (context) => {
|
|
|
19
19
|
if (config.value == null) {
|
|
20
20
|
throw new PluginMissconfigured('value');
|
|
21
21
|
}
|
|
22
|
-
const validateRecaptcha = context.
|
|
22
|
+
const validateRecaptcha = context.entrypoint(MOD_RECAPTCHA);
|
|
23
23
|
const [result, status] = await validateRecaptcha.call({
|
|
24
24
|
body: {
|
|
25
25
|
secret: config.value,
|
|
@@ -27,7 +27,7 @@ export const reCaptcha = (context) => {
|
|
|
27
27
|
},
|
|
28
28
|
headers: { 'content-type': 'application/x-www-form-urlencoded' }
|
|
29
29
|
});
|
|
30
|
-
if (status !==
|
|
30
|
+
if (status !== EntrypointOutcome.Ok) {
|
|
31
31
|
throw new AuthPluginError('recaptcha:api');
|
|
32
32
|
}
|
|
33
33
|
if (!result.success) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"re-captcha.js","sourceRoot":"","sources":["../../../src/manager/plugins/re-captcha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAGvH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"re-captcha.js","sourceRoot":"","sources":["../../../src/manager/plugins/re-captcha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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BACzF,IAAI,EAAE;oBACJ,MAAM,EAAE,MAAM,CAAC,KAAK;oBACpB,QAAQ,EAAE,UAAU,CAAC,UAAU;iBAChC;gBACD,OAAO,EAAE,EAAE,cAAc,EAAE,mCAAmC,EAAE;aACjE,CAAC,CAAA;YACF,IAAI,MAAM,KAAK,iBAAiB,CAAC,EAAE,EAAE,CAAC;gBACpC,MAAM,IAAI,eAAe,CAAC,eAAe,CAAC,CAAA;YAC5C,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,YAAY,CAAC,YAAY,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,CAAC,CAAA;YACxF,CAAC;YAED,UAAU,CAAC,MAAM,GAAG,CAAC,UAAU,CAAC,CAAA;YAChC,UAAU,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAA;YAChC,UAAU,CAAC,IAAI,GAAG,kBAAkB,CAAC,SAAS,CAAA;YAE9C,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAiC,CAAA;YAC7F,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACtB,UAAU,CAAC,SAAS,GAAG,QAAQ,CAAA;gBAE/B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;YAC5B,CAAC;YAED,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;QACtB,CAAC;KACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AllowanceResponse } from '@owlmeans/auth';
|
|
2
2
|
import type { AuthModel } from '../types.js';
|
|
3
|
-
import type { AbstractRequest } from '@owlmeans/
|
|
3
|
+
import type { AbstractRequest } from '@owlmeans/entrypoint';
|
|
4
4
|
import type { RedisResource } from '@owlmeans/redis-resource';
|
|
5
5
|
import type { ResourceRecord } from '@owlmeans/resource';
|
|
6
6
|
export interface AuthPlugin extends Omit<AuthModel, "rely"> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/manager/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/manager/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC;IACzD,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB;AAED,MAAM,WAAW,gBAAiB,SAAQ,eAAe,CAAC;IACxD,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAC;CAAI;AAEN,MAAM,WAAW,UAAW,SAAQ,cAAc,EAAE,iBAAiB;CACpE;AAED,MAAM,WAAW,iBAAkB,SAAQ,aAAa,CAAC,UAAU,CAAC;CAAG"}
|
|
@@ -4,5 +4,5 @@ export declare const assertType: (type: string, plugin: AuthPlugin) => void;
|
|
|
4
4
|
/**
|
|
5
5
|
* @throws {AuthUnknown}
|
|
6
6
|
*/
|
|
7
|
-
export declare const getPlugin: (type: string, context: AppContext<AppConfig>) => AuthPlugin
|
|
7
|
+
export declare const getPlugin: (type: string, context: AppContext<AppConfig>) => Promise<AuthPlugin>;
|
|
8
8
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/manager/plugins/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/manager/plugins/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAExD,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,QAAQ,UAAU,SAI1D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,GAAU,MAAM,MAAM,EAAE,SAAS,UAAU,CAAC,SAAS,CAAC,KAAG,OAAO,CAAC,UAAU,CAOhG,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AuthUnknown, TypeMissmatchError } from '@owlmeans/auth';
|
|
2
|
-
import { plugins } from './index.js';
|
|
3
2
|
export const assertType = (type, plugin) => {
|
|
4
3
|
if (type !== plugin.type) {
|
|
5
4
|
throw new TypeMissmatchError(plugin.type);
|
|
@@ -8,7 +7,8 @@ export const assertType = (type, plugin) => {
|
|
|
8
7
|
/**
|
|
9
8
|
* @throws {AuthUnknown}
|
|
10
9
|
*/
|
|
11
|
-
export const getPlugin = (type, context) => {
|
|
10
|
+
export const getPlugin = async (type, context) => {
|
|
11
|
+
const { plugins } = await import('./index.js');
|
|
12
12
|
const plugin = plugins[type];
|
|
13
13
|
if (plugin == null) {
|
|
14
14
|
throw new AuthUnknown(type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/manager/plugins/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/manager/plugins/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAIhE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,MAAkB,EAAE,EAAE;IAC7D,IAAI,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;QACzB,MAAM,IAAI,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,IAAY,EAAE,OAA8B,EAAuB,EAAE;IACnG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAA;IAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA;AAC/B,CAAC,CAAA"}
|
package/build/manager/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AllowanceRequest, AllowanceResponse, Auth, AuthCredentials, AuthToken, RelyToken } from '@owlmeans/auth';
|
|
2
2
|
import type { KlusterConfig } from '@owlmeans/kluster';
|
|
3
|
-
import type { GuardService } from '@owlmeans/
|
|
3
|
+
import type { GuardService } from '@owlmeans/entrypoint';
|
|
4
4
|
import type { ApiServerAppend } from '@owlmeans/server-api';
|
|
5
5
|
import type { ServerContext, ServerConfig } from '@owlmeans/server-context';
|
|
6
6
|
import type { ServiceRoute } from '@owlmeans/server-route';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/manager/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/manager/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAErE,MAAM,WAAW,SAAU,SAAQ,YAAY,EAAE,aAAa;IAC5D,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAE/D,YAAY,EAAE,CAAC,UAAU,EAAE,eAAe,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;IAEjE,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAChE;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC,EACjF,eAAe,EACf,oBAAoB;CAAI;AAE5B,MAAM,WAAW,WAAY,SAAQ,YAAY;CAChD;AAED,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,WAAW,CAAC,EAAE,UAAU,CAAA;IACxB,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACtE;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,SAAS,CAAA;CAChB"}
|
package/build/modules.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const modules:
|
|
1
|
+
import type { ServerEntrypoint } from '@owlmeans/server-entrypoint';
|
|
2
|
+
export declare const modules: ServerEntrypoint<unknown>[];
|
|
3
3
|
//# sourceMappingURL=modules.d.ts.map
|
package/build/modules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAOnE,eAAO,MAAM,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAK9C,CAAA"}
|
package/build/modules.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { elevate } from '@owlmeans/server-
|
|
1
|
+
import { elevate } from '@owlmeans/server-entrypoint';
|
|
2
2
|
import { modules as list } from '@owlmeans/auth-common';
|
|
3
3
|
import { DISPATCHER, DISPATCHER_AUTHEN } from '@owlmeans/auth';
|
|
4
4
|
import { authenticate } from './actions/service.js';
|
|
5
|
-
import { stab, elevate as celevate } from '@owlmeans/client-
|
|
5
|
+
import { stab, elevate as celevate } from '@owlmeans/client-entrypoint';
|
|
6
6
|
elevate(list, DISPATCHER_AUTHEN, authenticate);
|
|
7
7
|
celevate(list, DISPATCHER, stab);
|
|
8
8
|
export const modules = [
|
package/build/modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEvE,OAAO,CAAC,IAAI,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAA;AAC9C,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;AAEhC,MAAM,CAAC,MAAM,OAAO,GAAgC;IAClD,GAAG,IAAI,CAAC,MAAM,CACZ,CAAC,MAAM,EAAuC,EAAE,CAC9C,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAC9D;CACF,CAAA"}
|
package/build/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Auth, AuthToken } from '@owlmeans/auth';
|
|
2
|
-
import type { GuardService } from '@owlmeans/
|
|
2
|
+
import type { GuardService } from '@owlmeans/entrypoint';
|
|
3
3
|
import type { ResourceRecord } from '@owlmeans/resource';
|
|
4
4
|
export interface AuthService extends GuardService {
|
|
5
5
|
authenticate: (token: AuthToken) => Promise<AuthToken>;
|
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,IAAI,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;IACtD,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACzC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,WAAW,CAAA;CACxB;AAED,MAAM,WAAW,SAAU,SAAQ,cAAc;CAChD"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/server-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"build": "tsc -b",
|
|
7
8
|
"dev": "sleep 276 && nodemon -e ts,tsx,json --watch src --exec \"tsc -p ./tsconfig.json\"",
|
|
8
|
-
"watch": "tsc -b -w --preserveWatchOutput --pretty"
|
|
9
|
+
"watch": "tsc -b -w --preserveWatchOutput --pretty",
|
|
10
|
+
"test": "bun test ./tests"
|
|
9
11
|
},
|
|
10
12
|
"main": "build/index.js",
|
|
11
13
|
"module": "build/index.js",
|
|
@@ -35,39 +37,42 @@
|
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@noble/hashes": "^1.5.0",
|
|
38
|
-
"@owlmeans/api": "^0.1.
|
|
39
|
-
"@owlmeans/api-config-server": "^0.1.
|
|
40
|
-
"@owlmeans/auth": "^0.1.
|
|
41
|
-
"@owlmeans/auth-common": "^0.1.
|
|
42
|
-
"@owlmeans/basic-envelope": "^0.1.
|
|
43
|
-
"@owlmeans/basic-ids": "^0.1.
|
|
44
|
-
"@owlmeans/basic-keys": "^0.1.
|
|
45
|
-
"@owlmeans/client-config": "^0.1.
|
|
46
|
-
"@owlmeans/client-
|
|
47
|
-
"@owlmeans/config": "^0.1.
|
|
48
|
-
"@owlmeans/context": "^0.1.
|
|
49
|
-
"@owlmeans/kluster": "^0.1.
|
|
50
|
-
"@owlmeans/
|
|
51
|
-
"@owlmeans/redis-resource": "^0.1.
|
|
52
|
-
"@owlmeans/resource": "^0.1.
|
|
53
|
-
"@owlmeans/route": "^0.1.
|
|
54
|
-
"@owlmeans/server-api": "^0.1.
|
|
55
|
-
"@owlmeans/server-context": "^0.1.
|
|
56
|
-
"@owlmeans/server-
|
|
57
|
-
"@owlmeans/server-route": "^0.1.
|
|
58
|
-
"@owlmeans/server-socket": "^0.1.
|
|
59
|
-
"@owlmeans/socket": "^0.1.
|
|
60
|
-
"@owlmeans/static-resource": "^0.1.
|
|
40
|
+
"@owlmeans/api": "^0.1.3",
|
|
41
|
+
"@owlmeans/api-config-server": "^0.1.3",
|
|
42
|
+
"@owlmeans/auth": "^0.1.3",
|
|
43
|
+
"@owlmeans/auth-common": "^0.1.3",
|
|
44
|
+
"@owlmeans/basic-envelope": "^0.1.3",
|
|
45
|
+
"@owlmeans/basic-ids": "^0.1.3",
|
|
46
|
+
"@owlmeans/basic-keys": "^0.1.3",
|
|
47
|
+
"@owlmeans/client-config": "^0.1.3",
|
|
48
|
+
"@owlmeans/client-entrypoint": "^0.1.3",
|
|
49
|
+
"@owlmeans/config": "^0.1.3",
|
|
50
|
+
"@owlmeans/context": "^0.1.3",
|
|
51
|
+
"@owlmeans/kluster": "^0.1.3",
|
|
52
|
+
"@owlmeans/entrypoint": "^0.1.3",
|
|
53
|
+
"@owlmeans/redis-resource": "^0.1.3",
|
|
54
|
+
"@owlmeans/resource": "^0.1.3",
|
|
55
|
+
"@owlmeans/route": "^0.1.3",
|
|
56
|
+
"@owlmeans/server-api": "^0.1.3",
|
|
57
|
+
"@owlmeans/server-context": "^0.1.3",
|
|
58
|
+
"@owlmeans/server-entrypoint": "^0.1.3",
|
|
59
|
+
"@owlmeans/server-route": "^0.1.3",
|
|
60
|
+
"@owlmeans/server-socket": "^0.1.3",
|
|
61
|
+
"@owlmeans/socket": "^0.1.3",
|
|
62
|
+
"@owlmeans/static-resource": "^0.1.3",
|
|
61
63
|
"@scure/base": "^1.1.9"
|
|
62
64
|
},
|
|
63
65
|
"peerDependencies": {
|
|
64
66
|
"ajv": "*"
|
|
65
67
|
},
|
|
66
68
|
"devDependencies": {
|
|
69
|
+
"@owlmeans/dep-config": "workspace:*",
|
|
70
|
+
"@owlmeans/test-auth": "^0.1.2",
|
|
71
|
+
"@types/bun": "^1.3.0",
|
|
67
72
|
"@types/node": "^24.10.1",
|
|
68
73
|
"nodemon": "^3.1.11",
|
|
69
74
|
"npm-check": "^6.0.1",
|
|
70
|
-
"typescript": "^
|
|
75
|
+
"typescript": "^6.0.2"
|
|
71
76
|
},
|
|
72
77
|
"publishConfig": {
|
|
73
78
|
"access": "public"
|
package/src/actions/service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RefedEntrypointHandler } from '@owlmeans/server-entrypoint'
|
|
2
2
|
import type { AuthToken } from '@owlmeans/auth'
|
|
3
3
|
import { handleBody } from '@owlmeans/server-api'
|
|
4
4
|
import { AuthServiceAppend } from '../types.js'
|
|
@@ -8,7 +8,7 @@ import { assertContext } from '@owlmeans/context'
|
|
|
8
8
|
type Config = ServerConfig
|
|
9
9
|
type Context = ServerContext<Config> & AuthServiceAppend
|
|
10
10
|
|
|
11
|
-
export const authenticate:
|
|
11
|
+
export const authenticate: RefedEntrypointHandler<AuthToken> = handleBody(
|
|
12
12
|
async (payload: AuthToken, ctx) => {
|
|
13
13
|
const context = assertContext(ctx, 'authenticate') as Context
|
|
14
14
|
return await context.auth().authenticate(payload)
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { AllowanceRequest, AuthCredentials } from '@owlmeans/auth'
|
|
2
2
|
import { handleBody } from '@owlmeans/server-api'
|
|
3
3
|
import { makeAuthModel } from '../model.js'
|
|
4
|
-
import type {
|
|
4
|
+
import type { RefedEntrypointHandler } from '@owlmeans/server-entrypoint'
|
|
5
5
|
import type { AppContext, AppConfig } from '../types.js'
|
|
6
6
|
import { handleConnection } from '@owlmeans/server-socket'
|
|
7
7
|
|
|
8
|
-
export const authenticationInit:
|
|
8
|
+
export const authenticationInit: RefedEntrypointHandler<AllowanceRequest> = handleBody(
|
|
9
9
|
async (payload: AllowanceRequest, ctx) =>
|
|
10
10
|
await makeAuthModel(ctx as AppContext<AppConfig>).init(payload)
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
export const authenticate:
|
|
13
|
+
export const authenticate: RefedEntrypointHandler<AuthCredentials> = handleBody(
|
|
14
14
|
async (payload: AuthCredentials, ctx) =>
|
|
15
15
|
await makeAuthModel(ctx as AppContext<AppConfig>).authenticate(payload)
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
export const rely:
|
|
18
|
+
export const rely: RefedEntrypointHandler<void> = handleConnection(
|
|
19
19
|
// @TODO Request will contain information is there requrest
|
|
20
20
|
// privileged or not (privileged request implies auth provider)
|
|
21
21
|
async (conn, ctx, req) =>
|
package/src/manager/exports.ts
CHANGED
|
@@ -5,11 +5,11 @@ export { addWebService } from '@owlmeans/client-config'
|
|
|
5
5
|
export { service, TRUSTED } from '@owlmeans/config'
|
|
6
6
|
export { AppType, assertContext } from '@owlmeans/context'
|
|
7
7
|
export { klusterize } from '@owlmeans/kluster'
|
|
8
|
-
export { elevate } from '@owlmeans/server-
|
|
9
|
-
export { elevate as celevate, stab } from '@owlmeans/client-
|
|
10
|
-
export type {
|
|
8
|
+
export { elevate } from '@owlmeans/server-entrypoint'
|
|
9
|
+
export { elevate as celevate, stab } from '@owlmeans/client-entrypoint'
|
|
10
|
+
export type { RefedEntrypointHandler } from '@owlmeans/server-entrypoint'
|
|
11
11
|
export { handleIntermediate, handleBody, handleRequest, handleParams } from '@owlmeans/server-api'
|
|
12
|
-
export type { AbstractRequest, AbstractResponse } from '@owlmeans/
|
|
12
|
+
export type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint'
|
|
13
13
|
export { backend } from '@owlmeans/route'
|
|
14
14
|
|
|
15
15
|
export { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT } from '@owlmeans/auth'
|
package/src/manager/main.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { modules } from './modules.js'
|
|
|
3
3
|
import type { AppContext, AppConfig } from './types.js'
|
|
4
4
|
|
|
5
5
|
export const main = async <C extends AppConfig, T extends AppContext<C>>(ctx: T) => {
|
|
6
|
-
ctx.
|
|
6
|
+
ctx.registerEntrypoints(modules)
|
|
7
7
|
await ctx.configure().init()
|
|
8
8
|
await ctx.getApiServer().listen()
|
|
9
9
|
}
|
package/src/manager/model.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const makeAuthModel = (context: AppContext<AppConfig>): AuthModel => {
|
|
|
20
20
|
|
|
21
21
|
const model: AuthModel = {
|
|
22
22
|
init: async request => {
|
|
23
|
-
const plugin = getPlugin(request.type, context)
|
|
23
|
+
const plugin = await getPlugin(request.type, context)
|
|
24
24
|
const response = await plugin.init(request)
|
|
25
25
|
|
|
26
26
|
const envelope = makeEnvelopeModel(plugin.type)
|
|
@@ -63,7 +63,7 @@ export const makeAuthModel = (context: AppContext<AppConfig>): AuthModel => {
|
|
|
63
63
|
throw new AuthenPayloadError('userId')
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const plugin = getPlugin(envelope.type(), context)
|
|
66
|
+
const plugin = await getPlugin(envelope.type(), context)
|
|
67
67
|
|
|
68
68
|
// @TODO this token PROBABLY needs to be registered somewhere and rechecked
|
|
69
69
|
// from time to time to make sure that the session is not deleted
|
package/src/manager/modules.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT, AUTHEN_RELY, MOD_RECAPTCHA } from '@owlmeans/auth'
|
|
3
3
|
import { modules as list } from '@owlmeans/auth-common'
|
|
4
4
|
import { modules as apiConfig } from '@owlmeans/api-config-server'
|
|
5
|
-
import { elevate, guard } from '@owlmeans/server-
|
|
5
|
+
import { elevate, guard } from '@owlmeans/server-entrypoint'
|
|
6
6
|
import * as actions from './actions/index.js'
|
|
7
|
-
import {
|
|
7
|
+
import { entrypoint } from '@owlmeans/client-entrypoint'
|
|
8
8
|
import { backend, route, RouteMethod } from '@owlmeans/route'
|
|
9
9
|
import { handleIntermediate } from '@owlmeans/server-api'
|
|
10
10
|
import { DEFAULT_RELY } from './consts.js'
|
|
@@ -19,7 +19,7 @@ elevate(list, AUTHEN_RELY, actions.rely, guard(DEFAULT_RELY))
|
|
|
19
19
|
export const modules = list
|
|
20
20
|
list.push(...apiConfig)
|
|
21
21
|
list.push(
|
|
22
|
-
|
|
22
|
+
entrypoint(
|
|
23
23
|
route(MOD_RECAPTCHA, '/api/siteverify', backend({
|
|
24
24
|
host: 'https://www.google.com',
|
|
25
25
|
base: 'recaptcha',
|
|
@@ -4,8 +4,8 @@ import type { AuthPlugin, RecaptchaRequest, RecpatchaResponse } from './types.js
|
|
|
4
4
|
import { PLUGINS } from '@owlmeans/config'
|
|
5
5
|
import type { PluginConfig } from '@owlmeans/config'
|
|
6
6
|
import { PluginMissconfigured } from '@owlmeans/config'
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
7
|
+
import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
|
|
8
|
+
import { EntrypointOutcome } from '@owlmeans/entrypoint'
|
|
9
9
|
import { base64 } from '@scure/base'
|
|
10
10
|
import { randomBytes } from '@noble/hashes/utils'
|
|
11
11
|
import { assertType } from './utils.js'
|
|
@@ -28,7 +28,7 @@ export const reCaptcha = <C extends AppConfig, T extends AppContext<C>>(context:
|
|
|
28
28
|
if (config.value == null) {
|
|
29
29
|
throw new PluginMissconfigured('value')
|
|
30
30
|
}
|
|
31
|
-
const validateRecaptcha = context.
|
|
31
|
+
const validateRecaptcha = context.entrypoint<ClientEntrypoint<RecpatchaResponse>>(MOD_RECAPTCHA)
|
|
32
32
|
const [result, status] = await validateRecaptcha.call<RecpatchaResponse, RecaptchaRequest>({
|
|
33
33
|
body: {
|
|
34
34
|
secret: config.value,
|
|
@@ -36,7 +36,7 @@ export const reCaptcha = <C extends AppConfig, T extends AppContext<C>>(context:
|
|
|
36
36
|
},
|
|
37
37
|
headers: { 'content-type': 'application/x-www-form-urlencoded' }
|
|
38
38
|
})
|
|
39
|
-
if (status !==
|
|
39
|
+
if (status !== EntrypointOutcome.Ok) {
|
|
40
40
|
throw new AuthPluginError('recaptcha:api')
|
|
41
41
|
}
|
|
42
42
|
if (!result.success) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AllowanceResponse } from '@owlmeans/auth'
|
|
2
2
|
import type { AuthModel } from '../types.js'
|
|
3
|
-
import type { AbstractRequest } from '@owlmeans/
|
|
3
|
+
import type { AbstractRequest } from '@owlmeans/entrypoint'
|
|
4
4
|
import type { RedisResource } from '@owlmeans/redis-resource'
|
|
5
5
|
import type { ResourceRecord } from '@owlmeans/resource'
|
|
6
6
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AuthUnknown, TypeMissmatchError } from '@owlmeans/auth'
|
|
2
2
|
import type { AuthPlugin } from './types.js'
|
|
3
|
-
import { plugins } from './index.js'
|
|
4
3
|
import type { AppContext, AppConfig } from '../types.js'
|
|
5
4
|
|
|
6
5
|
export const assertType = (type: string, plugin: AuthPlugin) => {
|
|
@@ -12,7 +11,8 @@ export const assertType = (type: string, plugin: AuthPlugin) => {
|
|
|
12
11
|
/**
|
|
13
12
|
* @throws {AuthUnknown}
|
|
14
13
|
*/
|
|
15
|
-
export const getPlugin = (type: string, context: AppContext<AppConfig>): AuthPlugin => {
|
|
14
|
+
export const getPlugin = async (type: string, context: AppContext<AppConfig>): Promise<AuthPlugin> => {
|
|
15
|
+
const { plugins } = await import('./index.js')
|
|
16
16
|
const plugin = plugins[type]
|
|
17
17
|
if (plugin == null) {
|
|
18
18
|
throw new AuthUnknown(type)
|
package/src/manager/rely.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DEFAULT_RELY } from './consts.js'
|
|
|
3
3
|
import type { AppContext, RelyService } from './types.js'
|
|
4
4
|
import { AUTH_QUERY, AuthenFailed, AuthenticationType } from '@owlmeans/auth'
|
|
5
5
|
import type { Auth, AuthCredentials, AuthToken } from '@owlmeans/auth'
|
|
6
|
-
import type { AbstractRequest, AbstractResponse } from '@owlmeans/
|
|
6
|
+
import type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint'
|
|
7
7
|
import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope'
|
|
8
8
|
import type { ServerConfig, ServerContext } from '@owlmeans/server-context'
|
|
9
9
|
import { AUTH_CACHE, AUTHEN_TIMEFRAME } from '../consts.js'
|
package/src/manager/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AllowanceRequest, AllowanceResponse, Auth, AuthCredentials, AuthToken, RelyToken } from '@owlmeans/auth'
|
|
2
2
|
import type { KlusterConfig } from '@owlmeans/kluster'
|
|
3
|
-
import type { GuardService } from '@owlmeans/
|
|
3
|
+
import type { GuardService } from '@owlmeans/entrypoint'
|
|
4
4
|
import type { ApiServerAppend } from '@owlmeans/server-api'
|
|
5
5
|
import type { ServerContext, ServerConfig } from '@owlmeans/server-context'
|
|
6
6
|
import type { ServiceRoute } from '@owlmeans/server-route'
|
package/src/modules.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
import { elevate } from '@owlmeans/server-
|
|
2
|
+
import { elevate } from '@owlmeans/server-entrypoint'
|
|
3
3
|
import { modules as list } from '@owlmeans/auth-common'
|
|
4
4
|
import { DISPATCHER, DISPATCHER_AUTHEN } from '@owlmeans/auth'
|
|
5
|
-
import type {
|
|
5
|
+
import type { ServerEntrypoint } from '@owlmeans/server-entrypoint'
|
|
6
6
|
import { authenticate } from './actions/service.js'
|
|
7
|
-
import { stab, elevate as celevate } from '@owlmeans/client-
|
|
7
|
+
import { stab, elevate as celevate } from '@owlmeans/client-entrypoint'
|
|
8
8
|
|
|
9
9
|
elevate(list, DISPATCHER_AUTHEN, authenticate)
|
|
10
10
|
celevate(list, DISPATCHER, stab)
|
|
11
11
|
|
|
12
|
-
export const modules:
|
|
12
|
+
export const modules: ServerEntrypoint<unknown>[] = [
|
|
13
13
|
...list.filter(
|
|
14
|
-
(module): module is
|
|
14
|
+
(module): module is ServerEntrypoint<unknown> =>
|
|
15
15
|
[DISPATCHER, DISPATCHER_AUTHEN].includes(module.getAlias())
|
|
16
16
|
)
|
|
17
17
|
]
|
package/src/service.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { assertContext, createService } from '@owlmeans/context'
|
|
|
6
6
|
import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope'
|
|
7
7
|
import type { Auth, AuthCredentials } from '@owlmeans/auth'
|
|
8
8
|
import { AuthenFailed, AuthorizationError, AuthroizationType } from '@owlmeans/auth'
|
|
9
|
-
import type { AbstractRequest, AbstractResponse } from '
|
|
9
|
+
import type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint'
|
|
10
10
|
import type { Resource } from '@owlmeans/resource'
|
|
11
11
|
import { createStaticResource } from '@owlmeans/static-resource'
|
|
12
12
|
import { trust, extractAuthToken } from '@owlmeans/auth-common/utils'
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Auth, AuthToken } from '@owlmeans/auth'
|
|
2
|
-
import type { GuardService } from '@owlmeans/
|
|
2
|
+
import type { GuardService } from '@owlmeans/entrypoint'
|
|
3
3
|
import type { ResourceRecord } from '@owlmeans/resource'
|
|
4
4
|
|
|
5
5
|
export interface AuthService extends GuardService {
|
package/tests/context.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AppType, Layer, makeBasicContext } from '@owlmeans/context'
|
|
2
|
+
import type { BasicConfig, BasicContext } from '@owlmeans/context'
|
|
3
|
+
import { createStaticResource } from '@owlmeans/static-resource'
|
|
4
|
+
import { makeMemoryTrustedResource, makeFixtureKeyPair } from '@owlmeans/test-auth'
|
|
5
|
+
import type { TrustedRecord } from '@owlmeans/auth-common'
|
|
6
|
+
import { TRUSTED } from '@owlmeans/config'
|
|
7
|
+
import { AUTH_CACHE, AUTH_SRV_KEY, DEFAULT_ALIAS } from '../src/consts.js'
|
|
8
|
+
import { makeAuthService } from '../src/service.js'
|
|
9
|
+
|
|
10
|
+
const SERVICE_NAME = 'server-auth-tests'
|
|
11
|
+
const RESOURCE_KEY = 'server-auth-test-cache'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Build a test context with:
|
|
15
|
+
* - AUTH_CACHE static resource (anti-replay)
|
|
16
|
+
* - AUTH_SRV_KEY trusted record (external auth service key for verifying incoming credentials)
|
|
17
|
+
* - SERVICE_NAME trusted record (app's own key for signing outgoing bearers)
|
|
18
|
+
* - AuthService registered
|
|
19
|
+
*/
|
|
20
|
+
export const makeTestContext = () => {
|
|
21
|
+
const authServiceKP = makeFixtureKeyPair('auth-service-trusted')
|
|
22
|
+
const appKP = makeFixtureKeyPair('server-auth-app')
|
|
23
|
+
|
|
24
|
+
const authServiceRecord: TrustedRecord = {
|
|
25
|
+
id: authServiceKP.exportAddress(),
|
|
26
|
+
name: AUTH_SRV_KEY,
|
|
27
|
+
credential: authServiceKP.exportPublic(),
|
|
28
|
+
scopes: ['*'],
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const appRecord: TrustedRecord = {
|
|
32
|
+
id: appKP.exportAddress(),
|
|
33
|
+
name: SERVICE_NAME,
|
|
34
|
+
credential: appKP.exportPublic(),
|
|
35
|
+
secret: appKP.export(),
|
|
36
|
+
scopes: ['*'],
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const cfg: BasicConfig = {
|
|
40
|
+
ready: false,
|
|
41
|
+
service: SERVICE_NAME,
|
|
42
|
+
layer: Layer.Service,
|
|
43
|
+
type: AppType.Backend,
|
|
44
|
+
services: {},
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const context = makeBasicContext(cfg) as BasicContext<BasicConfig>
|
|
48
|
+
|
|
49
|
+
// Register trusted records (use TRUSTED alias so trust() can find them)
|
|
50
|
+
context.registerResource(makeMemoryTrustedResource([authServiceRecord, appRecord], TRUSTED))
|
|
51
|
+
|
|
52
|
+
// Register AUTH_CACHE static resource
|
|
53
|
+
context.registerResource(createStaticResource(AUTH_CACHE, RESOURCE_KEY))
|
|
54
|
+
|
|
55
|
+
// Register auth service
|
|
56
|
+
context.registerService(makeAuthService(DEFAULT_ALIAS))
|
|
57
|
+
|
|
58
|
+
return { context, authServiceKP, appKP, authServiceRecord }
|
|
59
|
+
}
|