@c9up/warden 0.2.5 → 0.2.6
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 +70 -3
- package/dist/AccessToken.d.ts +257 -0
- package/dist/AccessToken.d.ts.map +1 -0
- package/dist/AccessToken.js +370 -0
- package/dist/AccessToken.js.map +1 -0
- package/dist/AttemptStore.d.ts +16 -2
- package/dist/AttemptStore.d.ts.map +1 -1
- package/dist/AttemptStore.js +26 -12
- package/dist/AttemptStore.js.map +1 -1
- package/dist/AuthManager.d.ts +33 -2
- package/dist/AuthManager.d.ts.map +1 -1
- package/dist/AuthManager.js +23 -2
- package/dist/AuthManager.js.map +1 -1
- package/dist/Authenticator.d.ts +19 -1
- package/dist/Authenticator.d.ts.map +1 -1
- package/dist/Authenticator.js +37 -3
- package/dist/Authenticator.js.map +1 -1
- package/dist/Guard.d.ts.map +1 -1
- package/dist/Guard.js +17 -5
- package/dist/Guard.js.map +1 -1
- package/dist/ResilientBlacklistDriver.d.ts +23 -6
- package/dist/ResilientBlacklistDriver.d.ts.map +1 -1
- package/dist/ResilientBlacklistDriver.js +24 -8
- package/dist/ResilientBlacklistDriver.js.map +1 -1
- package/dist/WardenProvider.d.ts +2 -0
- package/dist/WardenProvider.d.ts.map +1 -1
- package/dist/WardenProvider.js +4 -58
- package/dist/WardenProvider.js.map +1 -1
- package/dist/config.d.ts +8 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mfa/MfaManager.d.ts +16 -4
- package/dist/mfa/MfaManager.d.ts.map +1 -1
- package/dist/mfa/MfaManager.js +32 -6
- package/dist/mfa/MfaManager.js.map +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +27 -5
- package/dist/middleware.js.map +1 -1
- package/dist/native.d.ts +6 -2
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js +19 -2
- package/dist/native.js.map +1 -1
- package/dist/quasar.d.ts.map +1 -1
- package/dist/quasar.js +8 -1
- package/dist/quasar.js.map +1 -1
- package/dist/standalone.d.ts +24 -3
- package/dist/standalone.d.ts.map +1 -1
- package/dist/standalone.js +21 -29
- package/dist/standalone.js.map +1 -1
- package/dist/strategies/ApiKeyStrategy.d.ts +45 -12
- package/dist/strategies/ApiKeyStrategy.d.ts.map +1 -1
- package/dist/strategies/ApiKeyStrategy.js +71 -37
- package/dist/strategies/ApiKeyStrategy.js.map +1 -1
- package/dist/strategies/JwtStrategy.d.ts.map +1 -1
- package/dist/strategies/JwtStrategy.js +3 -3
- package/dist/strategies/JwtStrategy.js.map +1 -1
- package/dist/templateTags.d.ts +42 -0
- package/dist/templateTags.d.ts.map +1 -0
- package/dist/templateTags.js +82 -0
- package/dist/templateTags.js.map +1 -0
- package/dist/vendor/nativeBinary.d.ts +26 -2
- package/dist/vendor/nativeBinary.d.ts.map +1 -1
- package/dist/vendor/nativeBinary.js +63 -6
- package/dist/vendor/nativeBinary.js.map +1 -1
- package/dist/vendor/quasarConnection.d.ts +26 -3
- package/dist/vendor/quasarConnection.d.ts.map +1 -1
- package/dist/vendor/quasarConnection.js +44 -23
- package/dist/vendor/quasarConnection.js.map +1 -1
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +7 -2
- package/src/AccessToken.ts +550 -0
- package/src/AttemptStore.ts +29 -13
- package/src/AuthManager.ts +40 -2
- package/src/Authenticator.ts +39 -3
- package/src/Guard.ts +18 -5
- package/src/ResilientBlacklistDriver.ts +28 -8
- package/src/WardenProvider.ts +6 -83
- package/src/config.ts +8 -4
- package/src/index.ts +18 -0
- package/src/mfa/MfaManager.ts +39 -6
- package/src/middleware.ts +36 -5
- package/src/native.ts +20 -4
- package/src/quasar.ts +13 -2
- package/src/standalone.ts +74 -33
- package/src/strategies/ApiKeyStrategy.ts +112 -42
- package/src/strategies/JwtStrategy.ts +3 -1
- package/src/templateTags.ts +117 -0
- package/src/vendor/nativeBinary.ts +82 -6
- package/src/vendor/quasarConnection.ts +84 -22
|
@@ -1,17 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Access-tokens authentication strategy (opaque API tokens).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Reads the token from `Authorization: Bearer <token>` or the configured
|
|
5
|
+
* header (`x-api-key` by default), verifies it through an access-tokens
|
|
6
|
+
* provider — which stores only a hash, compares in constant time and checks
|
|
7
|
+
* expiry — then loads the user it belongs to.
|
|
8
|
+
*
|
|
9
|
+
* The token's abilities stay ON THE TOKEN: the user is handed to the request
|
|
10
|
+
* with `currentAccessToken`, and a handler asks it
|
|
11
|
+
* (`ctx.auth.user.currentAccessToken.allows('orders:write')`). They are never
|
|
12
|
+
* merged into `user.permissions`, which holds the user's own permissions: a
|
|
13
|
+
* token whose ability happened to share a permission's name would otherwise
|
|
14
|
+
* grant that permission to a user who does not hold it, and a token restricted
|
|
15
|
+
* to a few abilities would still carry every permission of its user. Warden's
|
|
16
|
+
* permission checks (`@Permission`, `hasPermission`) require both: the user's
|
|
17
|
+
* permission AND the token's ability (`tokenAllows`).
|
|
5
18
|
*
|
|
6
19
|
* @implements MISS-8
|
|
7
20
|
*/
|
|
21
|
+
import type { AccessToken, AccessTokensProviderContract, CreateAccessTokenOptions, TokenOwner } from "../AccessToken.js";
|
|
8
22
|
import type { AuthClientResponse, AuthResult, AuthStrategy, UserPayload } from "../AuthManager.js";
|
|
9
23
|
export interface ApiKeyConfig {
|
|
24
|
+
/** Header read beside `Authorization: Bearer`. Default `x-api-key`. */
|
|
10
25
|
headerName?: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Verifies a presented token and mints new ones — an
|
|
28
|
+
* `AccessTokensProvider` over the application's token table, or the
|
|
29
|
+
* application's own implementation of the contract.
|
|
30
|
+
*/
|
|
31
|
+
tokens: AccessTokensProviderContract;
|
|
32
|
+
/**
|
|
33
|
+
* Load the user a verified token belongs to. Called on every request, so a
|
|
34
|
+
* token whose account was deleted or disabled stops working: answer `null`
|
|
35
|
+
* and the request is refused.
|
|
36
|
+
*/
|
|
37
|
+
findUser: (id: string | number) => Promise<UserPayload | null>;
|
|
15
38
|
}
|
|
16
39
|
export declare class ApiKeyStrategy implements AuthStrategy {
|
|
17
40
|
#private;
|
|
@@ -24,14 +47,24 @@ export declare class ApiKeyStrategy implements AuthStrategy {
|
|
|
24
47
|
password: string;
|
|
25
48
|
}): Promise<AuthResult>;
|
|
26
49
|
/**
|
|
27
|
-
*
|
|
28
|
-
* `
|
|
50
|
+
* Mint a token for `user` through the provider. The returned token carries
|
|
51
|
+
* `value` this once: hand it to the client now.
|
|
52
|
+
*/
|
|
53
|
+
createToken(user: TokenOwner, abilities?: string[], options?: CreateAccessTokenOptions): Promise<AccessToken>;
|
|
54
|
+
/**
|
|
55
|
+
* Revoke the token behind `value`. Answers whether it existed.
|
|
29
56
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
57
|
+
* NAMED DEVIATION — upstream's guard is built per request and revokes the
|
|
58
|
+
* token it authenticated with, so it takes no argument. A warden strategy
|
|
59
|
+
* is shared by every request and keeps none of them, so the value is passed
|
|
60
|
+
* in; a sign-out handler has it, it is the request's credential.
|
|
61
|
+
*/
|
|
62
|
+
invalidateToken(value: string): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* What a test client sends to be `user`: a real token, minted through the
|
|
65
|
+
* provider, so the test authenticates the way the application will.
|
|
33
66
|
*/
|
|
34
|
-
authenticateAsClient(
|
|
67
|
+
authenticateAsClient(user: TokenOwner, abilities?: string[], options?: CreateAccessTokenOptions): Promise<AuthClientResponse>;
|
|
35
68
|
verify(token: string): Promise<AuthResult>;
|
|
36
69
|
}
|
|
37
70
|
//# sourceMappingURL=ApiKeyStrategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiKeyStrategy.d.ts","sourceRoot":"","sources":["../../src/strategies/ApiKeyStrategy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ApiKeyStrategy.d.ts","sourceRoot":"","sources":["../../src/strategies/ApiKeyStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EACX,WAAW,EACX,4BAA4B,EAC5B,wBAAwB,EACxB,UAAU,EACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACX,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,YAAY;IAC5B,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,MAAM,EAAE,4BAA4B,CAAC;IACrC;;;;OAIG;IACH,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC/D;AAED,qBAAa,cAAe,YAAW,YAAY;;IAIlD,IAAI,SAAmB;gBAIX,MAAM,EAAE,YAAY;IAuBhC,wDAAwD;IACxD,IAAI,UAAU,IAAI,MAAM,CAEvB;IAEK,YAAY,CAAC,YAAY,EAAE;QAChC,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,UAAU,CAAC;IAMvB;;;OAGG;IACH,WAAW,CACV,IAAI,EAAE,UAAU,EAChB,SAAS,CAAC,EAAE,MAAM,EAAE,EACpB,OAAO,CAAC,EAAE,wBAAwB,GAChC,OAAO,CAAC,WAAW,CAAC;IAIvB;;;;;;;OAOG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhD;;;OAGG;IACG,oBAAoB,CACzB,IAAI,EAAE,UAAU,EAChB,SAAS,CAAC,EAAE,MAAM,EAAE,EACpB,OAAO,CAAC,EAAE,wBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC;IAYxB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAmBhD"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Access-tokens authentication strategy (opaque API tokens).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Reads the token from `Authorization: Bearer <token>` or the configured
|
|
5
|
+
* header (`x-api-key` by default), verifies it through an access-tokens
|
|
6
|
+
* provider — which stores only a hash, compares in constant time and checks
|
|
7
|
+
* expiry — then loads the user it belongs to.
|
|
8
|
+
*
|
|
9
|
+
* The token's abilities stay ON THE TOKEN: the user is handed to the request
|
|
10
|
+
* with `currentAccessToken`, and a handler asks it
|
|
11
|
+
* (`ctx.auth.user.currentAccessToken.allows('orders:write')`). They are never
|
|
12
|
+
* merged into `user.permissions`, which holds the user's own permissions: a
|
|
13
|
+
* token whose ability happened to share a permission's name would otherwise
|
|
14
|
+
* grant that permission to a user who does not hold it, and a token restricted
|
|
15
|
+
* to a few abilities would still carry every permission of its user. Warden's
|
|
16
|
+
* permission checks (`@Permission`, `hasPermission`) require both: the user's
|
|
17
|
+
* permission AND the token's ability (`tokenAllows`).
|
|
5
18
|
*
|
|
6
19
|
* @implements MISS-8
|
|
7
20
|
*/
|
|
21
|
+
import { WardenError } from "../errors.js";
|
|
22
|
+
import { Secret } from "../Secret.js";
|
|
8
23
|
export class ApiKeyStrategy {
|
|
9
24
|
// AdonisJS names this guard driver "access_tokens". The legacy "api-key"
|
|
10
25
|
// spelling is still accepted as a guard name / credential trigger by the
|
|
@@ -13,6 +28,17 @@ export class ApiKeyStrategy {
|
|
|
13
28
|
#config;
|
|
14
29
|
#headerName;
|
|
15
30
|
constructor(config) {
|
|
31
|
+
// A config written for the earlier `findByKey` shape has no provider:
|
|
32
|
+
// refused at boot rather than at the first request.
|
|
33
|
+
const tokens = Reflect.get(Object(config), "tokens");
|
|
34
|
+
if (typeof Reflect.get(Object(tokens), "verify") !== "function") {
|
|
35
|
+
throw new WardenError("INVALID_CONFIG", "The access-tokens guard needs `tokens`, a provider that verifies hashed tokens.", {
|
|
36
|
+
hint: "apiKeyGuard({ tokens: new AccessTokensProvider({ store }), findUser: (id) => User.find(id) })",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (typeof config.findUser !== "function") {
|
|
40
|
+
throw new WardenError("INVALID_CONFIG", "The access-tokens guard needs `findUser`, to load the user a token belongs to.");
|
|
41
|
+
}
|
|
16
42
|
this.#config = config;
|
|
17
43
|
this.#headerName = config.headerName ?? "x-api-key";
|
|
18
44
|
}
|
|
@@ -21,48 +47,56 @@ export class ApiKeyStrategy {
|
|
|
21
47
|
return this.#headerName;
|
|
22
48
|
}
|
|
23
49
|
async authenticate(_credentials) {
|
|
24
|
-
throw new Error("ApiKeyStrategy does not support credential-based auth. Use verify() with the
|
|
50
|
+
throw new Error("ApiKeyStrategy does not support credential-based auth. Use verify() with the access token.");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Mint a token for `user` through the provider. The returned token carries
|
|
54
|
+
* `value` this once: hand it to the client now.
|
|
55
|
+
*/
|
|
56
|
+
createToken(user, abilities, options) {
|
|
57
|
+
return this.#config.tokens.create(user, abilities, options);
|
|
25
58
|
}
|
|
26
59
|
/**
|
|
27
|
-
*
|
|
28
|
-
* `authenticateAsClient`).
|
|
60
|
+
* Revoke the token behind `value`. Answers whether it existed.
|
|
29
61
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
62
|
+
* NAMED DEVIATION — upstream's guard is built per request and revokes the
|
|
63
|
+
* token it authenticated with, so it takes no argument. A warden strategy
|
|
64
|
+
* is shared by every request and keeps none of them, so the value is passed
|
|
65
|
+
* in; a sign-out handler has it, it is the request's credential.
|
|
33
66
|
*/
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
67
|
+
invalidateToken(value) {
|
|
68
|
+
return this.#config.tokens.invalidate(new Secret(value));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* What a test client sends to be `user`: a real token, minted through the
|
|
72
|
+
* provider, so the test authenticates the way the application will.
|
|
73
|
+
*/
|
|
74
|
+
async authenticateAsClient(user, abilities, options) {
|
|
75
|
+
const token = await this.createToken(user, abilities, options);
|
|
76
|
+
const value = token.value?.release();
|
|
77
|
+
if (value === undefined) {
|
|
78
|
+
throw new WardenError("INVALID_CONFIG", "The token provider returned a token without its value from create().");
|
|
79
|
+
}
|
|
80
|
+
return { headers: { authorization: `Bearer ${value}` } };
|
|
41
81
|
}
|
|
42
82
|
async verify(token) {
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
return { authenticated: false, error: "Invalid
|
|
46
|
-
const user = { ...result.user };
|
|
47
|
-
if (result.scopes && result.scopes.length > 0) {
|
|
48
|
-
// Expose the API key's scopes on `user.permissions` (without mutating
|
|
49
|
-
// the source object) so APP code can read them via
|
|
50
|
-
// `ctx.auth.user.permissions`.
|
|
51
|
-
//
|
|
52
|
-
// IMPORTANT — these scopes are a SEPARATE axis from the `@Permission`
|
|
53
|
-
// route gate, by design (Adonis Bouncer parity): the gate flows through
|
|
54
|
-
// RightsResolver, which resolves grants from the rights STORE and
|
|
55
|
-
// deliberately ignores payload-carried permissions (see RightsResolver
|
|
56
|
-
// D1). This mirrors AdonisJS, where token abilities are checked via
|
|
57
|
-
// `currentAccessToken.allows(scope)` and are NOT consulted by Bouncer
|
|
58
|
-
// ability/policy checks. So an API key carrying `orders.create` is NOT
|
|
59
|
-
// auto-granted by `@Permission('orders.create')` — that's intentional,
|
|
60
|
-
// not a bug. Gate API-key routes on scopes with an explicit app-level
|
|
61
|
-
// check against `ctx.auth.user.permissions`.
|
|
62
|
-
const merged = new Set([...(user.permissions ?? []), ...result.scopes]);
|
|
63
|
-
user.permissions = [...merged];
|
|
83
|
+
const accessToken = await this.#config.tokens.verify(new Secret(token));
|
|
84
|
+
if (accessToken === null) {
|
|
85
|
+
return { authenticated: false, error: "Invalid access token" };
|
|
64
86
|
}
|
|
65
|
-
|
|
87
|
+
const user = await this.#config.findUser(accessToken.tokenableId);
|
|
88
|
+
if (!user) {
|
|
89
|
+
return {
|
|
90
|
+
authenticated: false,
|
|
91
|
+
error: "The account behind this token is no longer available",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
// A copy: the provider's object is the application's, and attaching the
|
|
95
|
+
// token to it would leak one request's token into the next.
|
|
96
|
+
return {
|
|
97
|
+
authenticated: true,
|
|
98
|
+
user: { ...user, currentAccessToken: accessToken },
|
|
99
|
+
};
|
|
66
100
|
}
|
|
67
101
|
}
|
|
68
102
|
//# sourceMappingURL=ApiKeyStrategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiKeyStrategy.js","sourceRoot":"","sources":["../../src/strategies/ApiKeyStrategy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ApiKeyStrategy.js","sourceRoot":"","sources":["../../src/strategies/ApiKeyStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAcH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAmBtC,MAAM,OAAO,cAAc;IAC1B,yEAAyE;IACzE,yEAAyE;IACzE,wEAAwE;IACxE,IAAI,GAAG,eAAe,CAAC;IACd,OAAO,CAAe;IACtB,WAAW,CAAS;IAE7B,YAAY,MAAoB;QAC/B,sEAAsE;QACtE,oDAAoD;QACpD,MAAM,MAAM,GAAY,OAAO,CAAC,GAAG,CAAC,MAA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AM,CAAC;IACf;;;;OAIG;IACH,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;;OAOG;IACH,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzE,iBAAiB,EAAE,CAClB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,KACZ,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACjC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,qBAAa,WAAY,YAAW,YAAY;;IAC/C,IAAI,SAAS;gBAaD,MAAM,EAAE,iBAAiB;IAoC/B,YAAY,CACjB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,UAAU,CAAC;IAkBhB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAyChD,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM;IAgBpE;;;;;;;;OAQG;IACH;;;;;;;OAOG;IACH,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,kBAAkB;IAIrD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAa7C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
6
6
|
import { resolveExpiresInSeconds } from "../duration.js";
|
|
7
|
-
import { nativeWarden } from "../native.js";
|
|
7
|
+
import { nativeWarden, nativeWardenLoadError } from "../native.js";
|
|
8
8
|
function sign(payload, secret) {
|
|
9
9
|
const rust = nativeWarden();
|
|
10
10
|
if (!rust) {
|
|
11
|
-
throw new Error("[E_WARDEN_NAPI_REQUIRED] The Rust warden-engine binary is required. Build it with `cd packages/warden && pnpm build:napi`.");
|
|
11
|
+
throw new Error("[E_WARDEN_NAPI_REQUIRED] The Rust warden-engine binary is required. Build it with `cd packages/warden && pnpm build:napi`.", { cause: nativeWardenLoadError() });
|
|
12
12
|
}
|
|
13
13
|
return rust.jwtSign(JSON.stringify(payload), secret);
|
|
14
14
|
}
|
|
15
15
|
function verify(token, secret) {
|
|
16
16
|
const rust = nativeWarden();
|
|
17
17
|
if (!rust) {
|
|
18
|
-
throw new Error("[E_WARDEN_NAPI_REQUIRED] The Rust warden-engine binary is required. Build it with `cd packages/warden && pnpm build:napi`.");
|
|
18
|
+
throw new Error("[E_WARDEN_NAPI_REQUIRED] The Rust warden-engine binary is required. Build it with `cd packages/warden && pnpm build:napi`.", { cause: nativeWardenLoadError() });
|
|
19
19
|
}
|
|
20
20
|
try {
|
|
21
21
|
const payloadJson = rust.jwtVerify(token, secret);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JwtStrategy.js","sourceRoot":"","sources":["../../src/strategies/JwtStrategy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOtD,OAAO,EAAE,uBAAuB,EAAsB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA+
|
|
1
|
+
{"version":3,"file":"JwtStrategy.js","sourceRoot":"","sources":["../../src/strategies/JwtStrategy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOtD,OAAO,EAAE,uBAAuB,EAAsB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,qBAAq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AAE,aAAa,EAAE,UAAU,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACd,0HAA0H,CAC1H,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;QACjC,IAAI,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE;YAAE,OAAO,KAAK,CAAC;QACtC,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED,MAAM,UAAU,iBAAiB;IAChC,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** The only surface warden needs of a template engine. */
|
|
2
|
+
export interface TemplateEngineLike {
|
|
3
|
+
registerTag(tag: {
|
|
4
|
+
tagName: string;
|
|
5
|
+
block: boolean;
|
|
6
|
+
seekable: boolean;
|
|
7
|
+
compile(parser: unknown, buffer: {
|
|
8
|
+
writeRaw(text: string): void;
|
|
9
|
+
}, token: {
|
|
10
|
+
properties: {
|
|
11
|
+
jsArg: string;
|
|
12
|
+
};
|
|
13
|
+
renderBody(): string | Promise<string>;
|
|
14
|
+
evaluate(expression: string): unknown;
|
|
15
|
+
}): void | Promise<void>;
|
|
16
|
+
}): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Register `@can` / `@cannot`, as AdonisJS's bouncer publishes them. A
|
|
20
|
+
* migrated template keeps `@can('PostPolicy.edit', post) … @endcan` unchanged.
|
|
21
|
+
*
|
|
22
|
+
* Both are BLOCK tags and both AWAIT — the check returns a promise — so they
|
|
23
|
+
* render on the async path and raise on a synchronous one, matching upstream
|
|
24
|
+
* (which emits `await bouncer.can(...)`). The checks themselves come from
|
|
25
|
+
* `ctx.bouncer.templateHelpers`, shared into the view per request.
|
|
26
|
+
*/
|
|
27
|
+
export declare function registerBouncerTemplateTags(engine: TemplateEngineLike): void;
|
|
28
|
+
/** Loads the template engine package. Swappable so a test needs no engine. */
|
|
29
|
+
export type EnginePackageLoader = () => Promise<unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* Publish the bouncer tags the way AdonisJS's bouncer does with Edge: through
|
|
32
|
+
* the engine package's MODULE SINGLETON (`inker.use(plugin)`), guarded by the
|
|
33
|
+
* host's `usingInker` flag — never by resolving a container binding. `use()`
|
|
34
|
+
* queues the plugin and the engine runs it before its next render, whenever
|
|
35
|
+
* the engine was built.
|
|
36
|
+
*
|
|
37
|
+
* Returns whether the tags were handed over. A registrar or an engine of the
|
|
38
|
+
* wrong shape is an error, not a skip: an unregistered `@can` would render as
|
|
39
|
+
* plain text and show the guarded body's markup to everyone.
|
|
40
|
+
*/
|
|
41
|
+
export declare function installBouncerTemplateTags(usingInker: boolean, load?: EnginePackageLoader): Promise<boolean>;
|
|
42
|
+
//# sourceMappingURL=templateTags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateTags.d.ts","sourceRoot":"","sources":["../src/templateTags.ts"],"names":[],"mappings":"AAEA,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,GAAG,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,OAAO,CAAC;QACf,QAAQ,EAAE,OAAO,CAAC;QAClB,OAAO,CACN,MAAM,EAAE,OAAO,EACf,MAAM,EAAE;YAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,EACxC,KAAK,EAAE;YACN,UAAU,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAA;aAAE,CAAC;YAC9B,UAAU,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;YACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;SACtC,GACC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACxB,GAAG,IAAI,CAAC;CACT;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CA0B5E;AAED,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAqBzD;;;;;;;;;;GAUG;AACH,wBAAsB,0BAA0B,CAC/C,UAAU,EAAE,OAAO,EACnB,IAAI,GAAE,mBAA+B,GACnC,OAAO,CAAC,OAAO,CAAC,CAuBlB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { WardenError } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Register `@can` / `@cannot`, as AdonisJS's bouncer publishes them. A
|
|
4
|
+
* migrated template keeps `@can('PostPolicy.edit', post) … @endcan` unchanged.
|
|
5
|
+
*
|
|
6
|
+
* Both are BLOCK tags and both AWAIT — the check returns a promise — so they
|
|
7
|
+
* render on the async path and raise on a synchronous one, matching upstream
|
|
8
|
+
* (which emits `await bouncer.can(...)`). The checks themselves come from
|
|
9
|
+
* `ctx.bouncer.templateHelpers`, shared into the view per request.
|
|
10
|
+
*/
|
|
11
|
+
export function registerBouncerTemplateTags(engine) {
|
|
12
|
+
for (const tagName of ["can", "cannot"]) {
|
|
13
|
+
engine.registerTag({
|
|
14
|
+
tagName,
|
|
15
|
+
block: true,
|
|
16
|
+
seekable: true,
|
|
17
|
+
async compile(_parser, buffer, token) {
|
|
18
|
+
// The shared bag lives in the render scope under `bouncer`.
|
|
19
|
+
const bouncer = token.evaluate("typeof bouncer === 'undefined' ? undefined : bouncer");
|
|
20
|
+
const check = Reflect.get(Object(bouncer), tagName);
|
|
21
|
+
if (typeof check !== "function") {
|
|
22
|
+
// No bouncer on this request: deny rather than render an
|
|
23
|
+
// unguarded body.
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const args = token.evaluate(`[${token.properties.jsArg}]`);
|
|
27
|
+
const allowed = await check.apply(bouncer, Array.isArray(args) ? args : []);
|
|
28
|
+
if (allowed === true)
|
|
29
|
+
buffer.writeRaw(await token.renderBody());
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const loadInker = () => {
|
|
35
|
+
// Built rather than written inline: inker is an OPTIONAL peer, and a
|
|
36
|
+
// literal `import("@c9up/inker")` makes a bundler resolve it at build time
|
|
37
|
+
// for an application that never installed it. Computed, it only runs
|
|
38
|
+
// behind the `usingInker` flag.
|
|
39
|
+
const specifier = "@c9up/inker";
|
|
40
|
+
return import(/* @vite-ignore */ specifier);
|
|
41
|
+
};
|
|
42
|
+
function unusable(detail) {
|
|
43
|
+
return new WardenError("E_WARDEN_TEMPLATE_ENGINE_UNUSABLE", `The template engine is installed but @can / @cannot cannot be registered: ${detail}`, {
|
|
44
|
+
hint: "`@c9up/inker` must default-export its plugin registrar (`inker.use(plugin)`), whose plugins receive an engine with `registerTag()`.",
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Publish the bouncer tags the way AdonisJS's bouncer does with Edge: through
|
|
49
|
+
* the engine package's MODULE SINGLETON (`inker.use(plugin)`), guarded by the
|
|
50
|
+
* host's `usingInker` flag — never by resolving a container binding. `use()`
|
|
51
|
+
* queues the plugin and the engine runs it before its next render, whenever
|
|
52
|
+
* the engine was built.
|
|
53
|
+
*
|
|
54
|
+
* Returns whether the tags were handed over. A registrar or an engine of the
|
|
55
|
+
* wrong shape is an error, not a skip: an unregistered `@can` would render as
|
|
56
|
+
* plain text and show the guarded body's markup to everyone.
|
|
57
|
+
*/
|
|
58
|
+
export async function installBouncerTemplateTags(usingInker, load = loadInker) {
|
|
59
|
+
if (!usingInker)
|
|
60
|
+
return false;
|
|
61
|
+
const module = await load();
|
|
62
|
+
const registrar = typeof module === "object" && module !== null
|
|
63
|
+
? Reflect.get(module, "default")
|
|
64
|
+
: undefined;
|
|
65
|
+
const use = Reflect.get(Object(registrar), "use");
|
|
66
|
+
if (typeof use !== "function") {
|
|
67
|
+
throw unusable("its default export has no use()");
|
|
68
|
+
}
|
|
69
|
+
use.call(registrar, (engine) => {
|
|
70
|
+
const register = Reflect.get(Object(engine), "registerTag");
|
|
71
|
+
if (typeof register !== "function") {
|
|
72
|
+
throw unusable("the engine has no registerTag()");
|
|
73
|
+
}
|
|
74
|
+
registerBouncerTemplateTags({
|
|
75
|
+
registerTag: (tag) => {
|
|
76
|
+
register.call(engine, tag);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=templateTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateTags.js","sourceRoot":"","sources":["../src/templateTags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAoB1C;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAA0B;IACrE,KAAK,MAAM,OAAO,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAU,EAAE,CAAC;QAClD,MAAM,CAAC,WAAW,CAAC;YAClB,OAAO;YACP,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;YACd,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK;gBACnC,4DAA4D;gBAC5D,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAC7B,sDAAsD,CACtD,CAAC;gBACF,MAAM,KAA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K,IAAI;QAC5C,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC;QAChC,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;IAClD,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,QAAQ,CAAC,iCAAiC,CAAC,CAAC;IACnD,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAe,EAAE,EAAE;QACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC;QAC5D,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACpC,MAAM,QAAQ,CAAC,iCAAiC,CAAC,CAAC;QACnD,CAAC;QACD,2BAA2B,CAAC;YAC3B,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE;gBACpB,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC5B,CAAC;SACD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -33,11 +33,35 @@ export type NativeBinaryResult<T> = {
|
|
|
33
33
|
cause?: unknown;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* The names among `names` that `value` does not carry as functions.
|
|
37
|
+
*
|
|
38
|
+
* Classes count, being functions, and so does a class's static member: `value`
|
|
39
|
+
* may itself be a function. What a guard rejects is only useful named, so the
|
|
40
|
+
* loader reports this list rather than a bare "no".
|
|
41
|
+
*/
|
|
42
|
+
export declare function missingFunctions(value: unknown, names: readonly string[]): string[];
|
|
43
|
+
/**
|
|
44
|
+
* Whether `value` carries every one of `names` as a function.
|
|
45
|
+
*
|
|
46
|
+
* The building block of the guard a package hands to `loadNativeBinary`, over
|
|
47
|
+
* the list of what it actually calls on its binary — the same list it passes
|
|
48
|
+
* as `expects`, so the message can name what is missing.
|
|
49
|
+
*/
|
|
50
|
+
export declare function hasFunctions(value: unknown, names: readonly string[]): value is object;
|
|
51
|
+
/**
|
|
52
|
+
* Load `<package root>/index.<suffix>.node`, and check it is the binary the
|
|
53
|
+
* package calls.
|
|
37
54
|
*
|
|
38
55
|
* The path is fixed rather than passed: this file is generated into
|
|
39
56
|
* `<package>/src/vendor/`, so the package root is always two levels up, from
|
|
40
57
|
* `src` and from `dist` alike.
|
|
58
|
+
*
|
|
59
|
+
* `isBinary` is the package's own check of what it calls. A declaration only
|
|
60
|
+
* says what the Rust promises: a stale build, or one from another version,
|
|
61
|
+
* loads just as well and then fails on the first missing call, far from here.
|
|
62
|
+
* A rejected module is reported as a failed load, so the package's policy
|
|
63
|
+
* (degrade or refuse) applies to it unchanged. `expects`, the list the guard is
|
|
64
|
+
* built from, lets that report name the missing calls.
|
|
41
65
|
*/
|
|
42
|
-
export declare function loadNativeBinary<T>(): NativeBinaryResult<T>;
|
|
66
|
+
export declare function loadNativeBinary<T>(isBinary: (value: unknown) => value is T, expects?: readonly string[]): NativeBinaryResult<T>;
|
|
43
67
|
//# sourceMappingURL=nativeBinary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeBinary.d.ts","sourceRoot":"","sources":["../../src/vendor/nativeBinary.ts"],"names":[],"mappings":"AAoCA;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,SAAS,MAAM,EAAE,CAEpD;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErE;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAEvD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAQzD;AAED;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,EAAE,GACtB,KAAK,IAAI,MAAM,CAQjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,EACxC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GACzB,kBAAkB,CAAC,CAAC,CAAC,CAoBvB"}
|
|
@@ -73,27 +73,84 @@ export function muslHint() {
|
|
|
73
73
|
? " On Alpine/musl, the gnu binary will not load — build the musl target."
|
|
74
74
|
: "";
|
|
75
75
|
}
|
|
76
|
+
/** Whether `value` carries a function under `name` (a napi class is one too). */
|
|
77
|
+
function hasFunction(value, name) {
|
|
78
|
+
const member = Reflect.get(value, name);
|
|
79
|
+
return typeof member === "function";
|
|
80
|
+
}
|
|
76
81
|
/**
|
|
77
|
-
*
|
|
82
|
+
* The names among `names` that `value` does not carry as functions.
|
|
83
|
+
*
|
|
84
|
+
* Classes count, being functions, and so does a class's static member: `value`
|
|
85
|
+
* may itself be a function. What a guard rejects is only useful named, so the
|
|
86
|
+
* loader reports this list rather than a bare "no".
|
|
87
|
+
*/
|
|
88
|
+
export function missingFunctions(value, names) {
|
|
89
|
+
if (value === null ||
|
|
90
|
+
(typeof value !== "object" && typeof value !== "function")) {
|
|
91
|
+
return [...names];
|
|
92
|
+
}
|
|
93
|
+
return names.filter((name) => !hasFunction(value, name));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether `value` carries every one of `names` as a function.
|
|
97
|
+
*
|
|
98
|
+
* The building block of the guard a package hands to `loadNativeBinary`, over
|
|
99
|
+
* the list of what it actually calls on its binary — the same list it passes
|
|
100
|
+
* as `expects`, so the message can name what is missing.
|
|
101
|
+
*/
|
|
102
|
+
export function hasFunctions(value, names) {
|
|
103
|
+
if (value === null ||
|
|
104
|
+
(typeof value !== "object" && typeof value !== "function")) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return missingFunctions(value, names).length === 0;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Load `<package root>/index.<suffix>.node`, and check it is the binary the
|
|
111
|
+
* package calls.
|
|
78
112
|
*
|
|
79
113
|
* The path is fixed rather than passed: this file is generated into
|
|
80
114
|
* `<package>/src/vendor/`, so the package root is always two levels up, from
|
|
81
115
|
* `src` and from `dist` alike.
|
|
116
|
+
*
|
|
117
|
+
* `isBinary` is the package's own check of what it calls. A declaration only
|
|
118
|
+
* says what the Rust promises: a stale build, or one from another version,
|
|
119
|
+
* loads just as well and then fails on the first missing call, far from here.
|
|
120
|
+
* A rejected module is reported as a failed load, so the package's policy
|
|
121
|
+
* (degrade or refuse) applies to it unchanged. `expects`, the list the guard is
|
|
122
|
+
* built from, lets that report name the missing calls.
|
|
82
123
|
*/
|
|
83
|
-
export function loadNativeBinary() {
|
|
124
|
+
export function loadNativeBinary(isBinary, expects) {
|
|
84
125
|
const suffix = nativeBinarySuffix();
|
|
85
126
|
if (suffix === undefined)
|
|
86
127
|
return { loaded: false, suffix };
|
|
87
128
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
129
|
+
let loaded;
|
|
88
130
|
try {
|
|
89
131
|
const nodeRequire = createRequire(import.meta.url);
|
|
90
|
-
|
|
91
|
-
loaded: true,
|
|
92
|
-
binary: nodeRequire(join(here, `../../index.${suffix}.node`)),
|
|
93
|
-
};
|
|
132
|
+
loaded = nodeRequire(join(here, `../../index.${suffix}.node`));
|
|
94
133
|
}
|
|
95
134
|
catch (cause) {
|
|
96
135
|
return { loaded: false, suffix, cause };
|
|
97
136
|
}
|
|
137
|
+
if (isBinary(loaded))
|
|
138
|
+
return { loaded: true, binary: loaded };
|
|
139
|
+
return {
|
|
140
|
+
loaded: false,
|
|
141
|
+
suffix,
|
|
142
|
+
cause: new Error(`index.${suffix}.node loaded, but ${rejection(loaded, expects)}. ` +
|
|
143
|
+
"The binary is stale or from another version: rebuild it."),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/** What a rejected binary lacks, or, without a list to check, what it has. */
|
|
147
|
+
function rejection(loaded, expects) {
|
|
148
|
+
const missing = expects === undefined ? [] : missingFunctions(loaded, expects);
|
|
149
|
+
if (missing.length > 0)
|
|
150
|
+
return `it lacks ${missing.join(", ")}`;
|
|
151
|
+
const exported = typeof loaded === "object" && loaded !== null
|
|
152
|
+
? Object.keys(loaded).filter((name) => hasFunction(loaded, name))
|
|
153
|
+
: [];
|
|
154
|
+
return `it is not the binary this package calls (it exports: ${exported.length > 0 ? exported.join(", ") : "none"})`;
|
|
98
155
|
}
|
|
99
156
|
//# sourceMappingURL=nativeBinary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeBinary.js","sourceRoot":"","sources":["../../src/vendor/nativeBinary.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,4EAA4E;AAE5E;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,gEAAgE;AAChE,MAAM,OAAO,GAA2B;IACvC,WAAW,EAAE,eAAe;IAC5B,aAAa,EAAE,iBAAiB;IAChC,YAAY,EAAE,YAAY;IAC1B,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,gBAAgB;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAChD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;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