@owlmeans/test-auth 0.1.18-rc.44 → 0.1.18-rc.46
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 +2 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/testing-auth-unit/SKILL.md +1 -1
- package/build/consts.local.d.ts +6 -0
- package/build/consts.local.d.ts.map +1 -0
- package/build/consts.local.js +7 -0
- package/build/consts.local.js.map +1 -0
- package/build/envelope.d.ts.map +1 -1
- package/build/envelope.js +1 -1
- package/build/envelope.js.map +1 -1
- package/build/guard.d.ts +4 -12
- package/build/guard.d.ts.map +1 -1
- package/build/guard.js +1 -1
- package/build/guard.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/trusted.d.ts +1 -1
- package/build/trusted.d.ts.map +1 -1
- package/build/trusted.js +1 -3
- package/build/trusted.js.map +1 -1
- package/build/types.d.ts +12 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/package.json +10 -10
- package/src/consts.local.ts +9 -0
- package/src/envelope.ts +1 -2
- package/src/guard.ts +4 -14
- package/src/index.ts +1 -0
- package/src/trusted.ts +2 -7
- package/src/types.ts +12 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Helpers exported here:
|
|
|
7
7
|
- `makeFixtureKeyPair(seed?)` — deterministic Ed25519 `KeyPairModel`.
|
|
8
8
|
- `makeMemoryTrustedResource(records?)` — `Resource<TrustedRecord>` satisfying `trust()` lookups against the `TRUSTED` config resource.
|
|
9
9
|
- `makeMockGuard({ alias?, auth?, allow? })` — `GuardService` that resolves to a chosen `Auth`. Implements `match`, `handle`, `authenticated`.
|
|
10
|
-
- `
|
|
10
|
+
- `appendMockGuard(ctx, auth, alias?)` — convenience that registers a mock guard with a chosen `Auth` on the context.
|
|
11
11
|
- `signMockEnvelope(msg, type, kind?, kp?)` — wraps `makeEnvelopeModel` with a fixture keypair to produce a signed envelope.
|
|
12
12
|
- `makeBearer(auth, kp?)` — `ED25519-BASIC-TOKEN <encoded>` header value for unit tests of header parsing.
|
|
13
13
|
- Canonical fixtures: `SUPERUSER`, `USER`, `SERVICE` `Auth` payloads.
|
|
@@ -20,7 +20,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
20
20
|
your project's skill store (`.agents/skills/`):
|
|
21
21
|
|
|
22
22
|
```sh
|
|
23
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
23
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.49
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/test-auth",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.46",
|
|
5
|
+
"generatedAt": "2026-10-05T21:03:06.365Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -6,7 +6,7 @@ description: Category-B unit tests for OwlMeans Common — auth/authz packages w
|
|
|
6
6
|
|
|
7
7
|
# Auth Unit Tests — Category B
|
|
8
8
|
|
|
9
|
-
**Install:** `"@owlmeans/test-auth": "^0.1.18-rc.
|
|
9
|
+
**Install:** `"@owlmeans/test-auth": "^0.1.18-rc.46"` in `devDependencies`
|
|
10
10
|
|
|
11
11
|
Category B applies to the auth/authz packages: `auth`, `auth-common`, `auth-otp`, `basic-envelope`, `basic-keys`, `client-auth`, `client-did`, `client-iam`, `client-payment`, `did`, `mui-oidc-rp`, `oidc`, `server-auth`, `server-auth-otp`, `server-oidc-provider`, `server-oidc-rp`, `web-auth`, `web-oidc-provider`, `web-oidc-rp`, `wled`. These tests run under `bun test` (no Playwright even when there are React bits) and are the **only** place mocks are allowed — and only for authentication/authorization, via `@owlmeans/test-auth`.
|
|
12
12
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const TRUSTED_DEFAULT_ALIAS = "TRUSTED";
|
|
2
|
+
/** The fields a `trust()` lookup keys on — the only index this map has. */
|
|
3
|
+
export declare const SUPPORTED_FIELDS: string[];
|
|
4
|
+
/** The scheme word of an `Authorization` header carrying an Ed25519 basic token. */
|
|
5
|
+
export declare const AUTH_BEARER_PREFIX: string;
|
|
6
|
+
//# sourceMappingURL=consts.local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.local.d.ts","sourceRoot":"","sources":["../src/consts.local.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,YAAY,CAAA;AAE9C,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,UAAiB,CAAA;AAE9C,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,QAAoD,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AuthroizationType } from '@owlmeans/auth';
|
|
2
|
+
export const TRUSTED_DEFAULT_ALIAS = 'TRUSTED';
|
|
3
|
+
/** The fields a `trust()` lookup keys on — the only index this map has. */
|
|
4
|
+
export const SUPPORTED_FIELDS = ['id', 'name'];
|
|
5
|
+
/** The scheme word of an `Authorization` header carrying an Ed25519 basic token. */
|
|
6
|
+
export const AUTH_BEARER_PREFIX = AuthroizationType.Ed25519BasicToken.toUpperCase();
|
|
7
|
+
//# sourceMappingURL=consts.local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.local.js","sourceRoot":"","sources":["../src/consts.local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAA;AAE9C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAE9C,oFAAoF;AACpF,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAA"}
|
package/build/envelope.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,MAAM,0BAA0B,CAAA;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,MAAM,0BAA0B,CAAA;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAI1C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAU,CAAC,SAAS,EAAE,GAAG,MAAM,OACrD,CAAC,QACA,MAAM,SACN,YAAY,OACd,YAAY,KACf,OAAO,CAAC,MAAM,CAKhB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,SACf,IAAI,OACL,YAAY,KAChB,OAAO,CAAC,MAAM,CAQhB,CAAA"}
|
package/build/envelope.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope';
|
|
2
2
|
import { AuthroizationType } from '@owlmeans/auth';
|
|
3
3
|
import { makeFixtureKeyPair } from './keys.js';
|
|
4
|
-
|
|
4
|
+
import { AUTH_BEARER_PREFIX } from './consts.local.js';
|
|
5
5
|
/**
|
|
6
6
|
* Wrap a payload in a signed `EnvelopeModel` using a fixture keypair (or one
|
|
7
7
|
* supplied by the caller) and serialize it. Useful in category-B tests that
|
package/build/envelope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../src/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACnC,GAAM,EACN,IAAY,EACZ,IAAI,GAAiB,YAAY,CAAC,KAAK,EACvC,EAAE,GAAiB,kBAAkB,CAAC,mBAAmB,CAAC,EACzC,EAAE;IACnB,MAAM,QAAQ,GAAG,iBAAiB,CAAI,IAAI,CAAC,CAAA;IAC3C,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAClB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IAC5C,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC7B,IAAU,EACV,EAAiB,EACA,EAAE;IACnB,MAAM,OAAO,GAAG,MAAM,gBAAgB,CACpC,IAA0C,EAC1C,iBAAiB,CAAC,iBAAiB,EACnC,YAAY,CAAC,KAAK,EAClB,EAAE,CACH,CAAA;IACD,OAAO,GAAG,kBAAkB,IAAI,OAAO,EAAE,CAAA;AAC3C,CAAC,CAAA"}
|
package/build/guard.d.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type BasicConfig, type BasicContext } from '@owlmeans/context';
|
|
2
2
|
import type { Auth } from '@owlmeans/auth';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
alias?: string;
|
|
6
|
-
/** Auth payload that `handle` will resolve into the response. */
|
|
7
|
-
auth?: Auth;
|
|
8
|
-
/** Optional predicate that decides whether `match` reports a hit. Defaults to "always match". */
|
|
9
|
-
allow?: (req: AbstractRequest, res: AbstractResponse<unknown>) => boolean | Promise<boolean>;
|
|
10
|
-
/** Token returned by the client-side `authenticated()` method. */
|
|
11
|
-
token?: string;
|
|
12
|
-
}
|
|
3
|
+
import type { GuardService } from '@owlmeans/entrypoint';
|
|
4
|
+
import type { MockGuardOptions } from './types.js';
|
|
13
5
|
/**
|
|
14
6
|
* Build a `GuardService` that resolves to a chosen `Auth` without exercising
|
|
15
7
|
* any real cryptography or trusted-record lookup. Use this in category-B
|
|
@@ -26,5 +18,5 @@ export declare const makeMockGuard: (opts?: MockGuardOptions) => GuardService;
|
|
|
26
18
|
* Returns the same context for chaining. Existing guards under the same
|
|
27
19
|
* alias are not replaced — register before any real guard service.
|
|
28
20
|
*/
|
|
29
|
-
export declare const
|
|
21
|
+
export declare const appendMockGuard: <C extends BasicConfig, T extends BasicContext<C>>(context: T, auth: Auth, alias?: string) => T;
|
|
30
22
|
//# sourceMappingURL=guard.d.ts.map
|
package/build/guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEtF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,UAAU,gBAAgB,KAAQ,YAsB3D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,WACrE,CAAC,QACJ,IAAI,UACH,MAAM,KACZ,CAGF,CAAA"}
|
package/build/guard.js
CHANGED
|
@@ -33,7 +33,7 @@ export const makeMockGuard = (opts = {}) => {
|
|
|
33
33
|
* Returns the same context for chaining. Existing guards under the same
|
|
34
34
|
* alias are not replaced — register before any real guard service.
|
|
35
35
|
*/
|
|
36
|
-
export const
|
|
36
|
+
export const appendMockGuard = (context, auth, alias = DEFAULT_GUARD) => {
|
|
37
37
|
const guard = makeMockGuard({ alias, auth });
|
|
38
38
|
return context.registerService(guard);
|
|
39
39
|
};
|
package/build/guard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuC,MAAM,mBAAmB,CAAA;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAKrD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAI,GAAqB,EAAE,EAAgB,EAAE;IACzE,MAAM,K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e,CAAA;AAC7B,cAAc,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,mBAAmB,YAAY,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAE1B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
|
package/build/trusted.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TrustedRecord } from '@owlmeans/auth-common';
|
|
2
|
-
import type
|
|
2
|
+
import { type Resource } from '@owlmeans/resource';
|
|
3
3
|
/**
|
|
4
4
|
* In-memory `Resource<TrustedRecord>` used to satisfy `trust()` lookups
|
|
5
5
|
* (`@owlmeans/auth-common/utils/trusted.ts`). Pre-populate with the
|
package/build/trusted.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trusted.d.ts","sourceRoot":"","sources":["../src/trusted.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"trusted.d.ts","sourceRoot":"","sources":["../src/trusted.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAoC,KAAK,QAAQ,EAA4B,MAAM,oBAAoB,CAAA;AAU9G;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,aAC3B,aAAa,EAAE,UACjB,MAAM,KACZ,QAAQ,CAAC,aAAa,CAqExB,CAAA"}
|
package/build/trusted.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { appendContextual } from '@owlmeans/context';
|
|
2
2
|
import { UnsupportedArgumentError } from '@owlmeans/resource';
|
|
3
|
-
|
|
4
|
-
/** The fields a `trust()` lookup keys on — the only index this map has. */
|
|
5
|
-
const SUPPORTED_FIELDS = ['id', 'name'];
|
|
3
|
+
import { SUPPORTED_FIELDS, TRUSTED_DEFAULT_ALIAS } from './consts.local.js';
|
|
6
4
|
const notImplemented = (op) => {
|
|
7
5
|
throw new Error(`@owlmeans/test-auth: in-memory TRUSTED resource does not implement ${op}()`);
|
|
8
6
|
};
|
package/build/trusted.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trusted.js","sourceRoot":"","sources":["../src/trusted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"trusted.js","sourceRoot":"","sources":["../src/trusted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,EAAmD,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAC9G,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE3E,MAAM,cAAc,GAAG,CAAC,EAAU,EAAS,EAAE;IAC3C,MAAM,IAAI,KAAK,CAAC,sEAAsE,EAAE,IAAI,CAAC,CAAA;AAC/F,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,CAAC,MAAqB,EAAE,KAAa,EAAW,EAAE,CAC9D,MAA6C,CAAC,KAAK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AG,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC;QAChC,IAAI,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC;QAClC,KAAK,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC;QACpC,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC;QACtC,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC;QACtC,IAAI,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC;QAClC,KAAK,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC;KACrC,CAAA;IAED,OAAO,gBAAgB,CAA0B,KAAK,EAAE,QAAQ,CAAC,CAAA;AACnE,CAAC,CAAA"}
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Auth } from '@owlmeans/auth';
|
|
2
|
+
import type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint';
|
|
3
|
+
export interface MockGuardOptions {
|
|
4
|
+
alias?: string;
|
|
5
|
+
/** Auth payload that `handle` will resolve into the response. */
|
|
6
|
+
auth?: Auth;
|
|
7
|
+
/** Optional predicate that decides whether `match` reports a hit. Defaults to "always match". */
|
|
8
|
+
allow?: (req: AbstractRequest, res: AbstractResponse<unknown>) => boolean | Promise<boolean>;
|
|
9
|
+
/** Token returned by the client-side `authenticated()` method. */
|
|
10
|
+
token?: string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE7E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iEAAiE;IACjE,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,iGAAiG;IACjG,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC5F,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
|
package/build/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/test-auth",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.46",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
25
|
-
"@owlmeans/auth-common": "^0.1.18-rc.
|
|
26
|
-
"@owlmeans/basic-envelope": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/basic-keys": "^0.1.18-rc.
|
|
28
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
29
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
30
|
-
"@owlmeans/resource": "^0.1.18-rc.
|
|
31
|
-
"@owlmeans/test": "^0.1.18-rc.
|
|
24
|
+
"@owlmeans/auth": "^0.1.18-rc.40",
|
|
25
|
+
"@owlmeans/auth-common": "^0.1.18-rc.47",
|
|
26
|
+
"@owlmeans/basic-envelope": "^0.1.18-rc.46",
|
|
27
|
+
"@owlmeans/basic-keys": "^0.1.18-rc.48",
|
|
28
|
+
"@owlmeans/context": "^0.1.18-rc.34",
|
|
29
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.41",
|
|
30
|
+
"@owlmeans/resource": "^0.1.18-rc.40",
|
|
31
|
+
"@owlmeans/test": "^0.1.18-rc.35"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@owlmeans/dep-config": "workspace:*",
|
|
35
|
-
"@types/bun": "^1.4.
|
|
35
|
+
"@types/bun": "^1.4.2",
|
|
36
36
|
"nodemon": "^3.1.14",
|
|
37
37
|
"typescript": "^7.0.2"
|
|
38
38
|
},
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AuthroizationType } from '@owlmeans/auth'
|
|
2
|
+
|
|
3
|
+
export const TRUSTED_DEFAULT_ALIAS = 'TRUSTED'
|
|
4
|
+
|
|
5
|
+
/** The fields a `trust()` lookup keys on — the only index this map has. */
|
|
6
|
+
export const SUPPORTED_FIELDS = ['id', 'name']
|
|
7
|
+
|
|
8
|
+
/** The scheme word of an `Authorization` header carrying an Ed25519 basic token. */
|
|
9
|
+
export const AUTH_BEARER_PREFIX = AuthroizationType.Ed25519BasicToken.toUpperCase()
|
package/src/envelope.ts
CHANGED
|
@@ -3,8 +3,7 @@ import type { KeyPairModel } from '@owlmeans/basic-keys'
|
|
|
3
3
|
import { AuthroizationType } from '@owlmeans/auth'
|
|
4
4
|
import type { Auth } from '@owlmeans/auth'
|
|
5
5
|
import { makeFixtureKeyPair } from './keys.js'
|
|
6
|
-
|
|
7
|
-
const AUTH_BEARER_PREFIX = AuthroizationType.Ed25519BasicToken.toUpperCase()
|
|
6
|
+
import { AUTH_BEARER_PREFIX } from './consts.local.js'
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Wrap a payload in a signed `EnvelopeModel` using a fixture keypair (or one
|
package/src/guard.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import { createService } from '@owlmeans/context'
|
|
2
|
-
import type { BasicConfig, BasicContext } from '@owlmeans/context'
|
|
1
|
+
import { createService, type BasicConfig, type BasicContext } from '@owlmeans/context'
|
|
3
2
|
import { DEFAULT_GUARD } from '@owlmeans/auth-common'
|
|
4
3
|
import type { Auth } from '@owlmeans/auth'
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
export interface MockGuardOptions {
|
|
8
|
-
alias?: string
|
|
9
|
-
/** Auth payload that `handle` will resolve into the response. */
|
|
10
|
-
auth?: Auth
|
|
11
|
-
/** Optional predicate that decides whether `match` reports a hit. Defaults to "always match". */
|
|
12
|
-
allow?: (req: AbstractRequest, res: AbstractResponse<unknown>) => boolean | Promise<boolean>
|
|
13
|
-
/** Token returned by the client-side `authenticated()` method. */
|
|
14
|
-
token?: string
|
|
15
|
-
}
|
|
4
|
+
import type { GuardService } from '@owlmeans/entrypoint'
|
|
5
|
+
import type { MockGuardOptions } from './types.js'
|
|
16
6
|
|
|
17
7
|
/**
|
|
18
8
|
* Build a `GuardService` that resolves to a chosen `Auth` without exercising
|
|
@@ -53,7 +43,7 @@ export const makeMockGuard = (opts: MockGuardOptions = {}): GuardService => {
|
|
|
53
43
|
* Returns the same context for chaining. Existing guards under the same
|
|
54
44
|
* alias are not replaced — register before any real guard service.
|
|
55
45
|
*/
|
|
56
|
-
export const
|
|
46
|
+
export const appendMockGuard = <C extends BasicConfig, T extends BasicContext<C>>(
|
|
57
47
|
context: T,
|
|
58
48
|
auth: Auth,
|
|
59
49
|
alias: string = DEFAULT_GUARD
|
package/src/index.ts
CHANGED
package/src/trusted.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { appendContextual } from '@owlmeans/context'
|
|
2
2
|
import type { TrustedRecord } from '@owlmeans/auth-common'
|
|
3
|
-
import type
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const TRUSTED_DEFAULT_ALIAS = 'TRUSTED'
|
|
7
|
-
|
|
8
|
-
/** The fields a `trust()` lookup keys on — the only index this map has. */
|
|
9
|
-
const SUPPORTED_FIELDS = ['id', 'name']
|
|
3
|
+
import { type Criteria, type FirstOptions, type Resource, UnsupportedArgumentError } from '@owlmeans/resource'
|
|
4
|
+
import { SUPPORTED_FIELDS, TRUSTED_DEFAULT_ALIAS } from './consts.local.js'
|
|
10
5
|
|
|
11
6
|
const notImplemented = (op: string): never => {
|
|
12
7
|
throw new Error(`@owlmeans/test-auth: in-memory TRUSTED resource does not implement ${op}()`)
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Auth } from '@owlmeans/auth'
|
|
2
|
+
import type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint'
|
|
3
|
+
|
|
4
|
+
export interface MockGuardOptions {
|
|
5
|
+
alias?: string
|
|
6
|
+
/** Auth payload that `handle` will resolve into the response. */
|
|
7
|
+
auth?: Auth
|
|
8
|
+
/** Optional predicate that decides whether `match` reports a hit. Defaults to "always match". */
|
|
9
|
+
allow?: (req: AbstractRequest, res: AbstractResponse<unknown>) => boolean | Promise<boolean>
|
|
10
|
+
/** Token returned by the client-side `authenticated()` method. */
|
|
11
|
+
token?: string
|
|
12
|
+
}
|