@c9up/warden 0.1.0 → 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/index.darwin-arm64.node
CHANGED
|
Binary file
|
package/index.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
package/index.linux-x64-gnu.node
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/src/WardenProvider.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { WardenConfig } from "./config.js";
|
|
|
3
3
|
import { WardenError } from "./errors.js";
|
|
4
4
|
import { MemoryRightsStore } from "./rights/MemoryRightsStore.js";
|
|
5
5
|
import { RightsResolver } from "./rights/RightsResolver.js";
|
|
6
|
-
import {
|
|
6
|
+
import { setAuth } from "./services/main.js";
|
|
7
7
|
import { JwtStrategy } from "./strategies/JwtStrategy.js";
|
|
8
8
|
|
|
9
9
|
interface WardenContainer {
|
|
@@ -79,6 +79,6 @@ export default class WardenProvider {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
async boot() {
|
|
82
|
-
|
|
82
|
+
setAuth(this.app.container.resolve(AuthManager) as AuthManager);
|
|
83
83
|
}
|
|
84
84
|
}
|
package/src/services/main.ts
CHANGED
|
@@ -12,28 +12,28 @@
|
|
|
12
12
|
|
|
13
13
|
import type { AuthManager } from "../AuthManager.js";
|
|
14
14
|
|
|
15
|
-
let
|
|
15
|
+
let instance: AuthManager | undefined;
|
|
16
16
|
|
|
17
17
|
/** @internal Bind the singleton (called by WardenProvider). */
|
|
18
|
-
export function
|
|
19
|
-
|
|
18
|
+
export function setAuth(value: AuthManager): void {
|
|
19
|
+
instance = value;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/** @internal Read the singleton (or `undefined` pre-boot). */
|
|
23
|
-
export function
|
|
24
|
-
return
|
|
23
|
+
export function getAuth(): AuthManager | undefined {
|
|
24
|
+
return instance;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const auth: AuthManager = new Proxy({} as AuthManager, {
|
|
28
28
|
get(_target, prop) {
|
|
29
|
-
if (!
|
|
29
|
+
if (!instance) {
|
|
30
30
|
throw new Error(
|
|
31
31
|
"[warden] AuthManager singleton accessed before WardenProvider.boot() ran. " +
|
|
32
32
|
"Check that `@c9up/warden/provider` is listed in your reamrc.ts providers.",
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
|
-
const value = Reflect.get(
|
|
36
|
-
return typeof value === "function" ? value.bind(
|
|
35
|
+
const value = Reflect.get(instance, prop, instance);
|
|
36
|
+
return typeof value === "function" ? value.bind(instance) : value;
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
39
|
|