@owlmeans/server-api 0.1.18-rc.50 → 0.1.18-rc.52
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 +20 -19
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-api/SKILL.md +9 -9
- package/build/server.js +3 -3
- package/build/server.js.map +1 -1
- package/build/utils/context/types.d.ts +13 -0
- package/build/utils/context/types.d.ts.map +1 -0
- package/build/utils/context/types.js +2 -0
- package/build/utils/context/types.js.map +1 -0
- package/build/utils/context.d.ts +3 -3
- package/build/utils/context.d.ts.map +1 -1
- package/build/utils/context.js +5 -2
- package/build/utils/context.js.map +1 -1
- package/build/utils/error/types.d.ts +52 -0
- package/build/utils/error/types.d.ts.map +1 -0
- package/build/utils/error/types.js +2 -0
- package/build/utils/error/types.js.map +1 -0
- package/build/utils/error.d.ts +4 -47
- package/build/utils/error.d.ts.map +1 -1
- package/build/utils/error.js +154 -187
- package/build/utils/error.js.map +1 -1
- package/build/utils/guards.d.ts.map +1 -1
- package/build/utils/guards.js +6 -6
- package/build/utils/guards.js.map +1 -1
- package/build/utils/index.d.ts +4 -1
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/payload/types.d.ts +18 -0
- package/build/utils/payload/types.d.ts.map +1 -0
- package/build/utils/payload/types.js +2 -0
- package/build/utils/payload/types.js.map +1 -0
- package/build/utils/payload.d.ts +3 -15
- package/build/utils/payload.d.ts.map +1 -1
- package/build/utils/payload.js +40 -60
- package/build/utils/payload.js.map +1 -1
- package/build/utils/schema.d.ts +7 -0
- package/build/utils/schema.d.ts.map +1 -0
- package/build/utils/schema.js +20 -0
- package/build/utils/schema.js.map +1 -0
- package/build/utils/server.js +6 -6
- package/build/utils/server.js.map +1 -1
- package/package.json +12 -12
- package/src/server.ts +3 -3
- package/src/utils/context/types.ts +13 -0
- package/src/utils/context.ts +9 -4
- package/src/utils/error/types.ts +52 -0
- package/src/utils/error.ts +156 -186
- package/src/utils/guards.ts +6 -6
- package/src/utils/index.ts +4 -1
- package/src/utils/payload/types.ts +18 -0
- package/src/utils/payload.ts +41 -63
- package/src/utils/schema.ts +23 -0
- package/src/utils/server.ts +6 -6
- package/tests/error-status.spec.ts +11 -11
package/build/utils/error.js
CHANGED
|
@@ -6,194 +6,161 @@ import { randomUUID } from 'node:crypto';
|
|
|
6
6
|
import { logger } from '@owlmeans/log';
|
|
7
7
|
import { CLIENT_ERROR_FIRST, CLIENT_ERROR_LAST, SERVER_ERROR_FIRST, SERVER_ERROR_LAST } from './consts.local.js';
|
|
8
8
|
import { INCIDENT_ID_HEADER } from './consts.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (typeof status !== 'number' || !Number.isInteger(status)) {
|
|
9
|
+
export const createHttpErrorHelper = () => {
|
|
10
|
+
const declaredErrorStatus = (error) => {
|
|
11
|
+
if (error == null || typeof error !== 'object') {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const declaration = error.constructor;
|
|
15
|
+
const status = declaration?.httpStatus;
|
|
16
|
+
if (typeof status !== 'number' || !Number.isInteger(status)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (status >= CLIENT_ERROR_FIRST && status <= CLIENT_ERROR_LAST)
|
|
20
|
+
return status;
|
|
21
|
+
if (status >= SERVER_ERROR_FIRST && status <= SERVER_ERROR_LAST
|
|
22
|
+
&& declaration?.allowServerErrorStatus === true)
|
|
23
|
+
return status;
|
|
25
24
|
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// No usable credential — absent, expired, revoked, or naming a session this server no longer
|
|
92
|
-
// holds. The caller is told to sign in, not that signing in would not help.
|
|
93
|
-
return UNAUTHORIZED_ERROR;
|
|
94
|
-
}
|
|
95
|
-
return declaredErrorStatus(error) ?? SERVER_ERROR;
|
|
96
|
-
};
|
|
97
|
-
/** Invalid or absent configuration always resolves to the production-safe policy. */
|
|
98
|
-
export const errorExposure = (config) => config?.http?.errors?.exposure === 'development' ? 'development' : 'production';
|
|
99
|
-
/**
|
|
100
|
-
* Preserve a typed/marshalled error when possible without asking `ensure` to convert a plain
|
|
101
|
-
* error. In particular, `ensure` deliberately rethrows SyntaxError; an HTTP boundary still has
|
|
102
|
-
* to serialize it safely and let the incident log retain the original object.
|
|
103
|
-
*/
|
|
104
|
-
const normalizeForWire = (error) => {
|
|
105
|
-
if (error instanceof SyntaxError || isResilientError(error)) {
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The registered type names an error carries: its own `type`, and the static `typeName` of every
|
|
28
|
+
* class on its constructor chain.
|
|
29
|
+
*
|
|
30
|
+
* This is how a class is recognised when `instanceof` cannot see it. A process that loads a package
|
|
31
|
+
* twice — `bun --preserve-symlinks` over a linked workspace resolves one package through several
|
|
32
|
+
* `node_modules` paths — holds several copies of every error class, and an error built by one copy
|
|
33
|
+
* is not an instance of another. The registered names are the same in every copy. A subclass's
|
|
34
|
+
* `typeName` does not reliably embed its parent's (`EntitlementRefusal` extends `AuthForbidden`), so
|
|
35
|
+
* a family is recognised by walking the chain and matching names exactly, never by a substring.
|
|
36
|
+
*/
|
|
37
|
+
const typeNamesOf = (error) => {
|
|
38
|
+
const names = new Set();
|
|
39
|
+
const type = error.type;
|
|
40
|
+
if (typeof type === 'string') {
|
|
41
|
+
names.add(type);
|
|
42
|
+
}
|
|
43
|
+
let ctor = error.constructor;
|
|
44
|
+
while (typeof ctor === 'function') {
|
|
45
|
+
const name = ctor.typeName;
|
|
46
|
+
if (typeof name === 'string') {
|
|
47
|
+
names.add(name);
|
|
48
|
+
}
|
|
49
|
+
ctor = Object.getPrototypeOf(ctor);
|
|
50
|
+
}
|
|
51
|
+
return names;
|
|
52
|
+
};
|
|
53
|
+
const isOfFamily = (names, family) => family.some(typeName => names.has(typeName));
|
|
54
|
+
const errorStatus = (error) => {
|
|
55
|
+
if (error == null || typeof error !== 'object') {
|
|
56
|
+
return SERVER_ERROR;
|
|
57
|
+
}
|
|
58
|
+
const names = typeNamesOf(error);
|
|
59
|
+
if (error instanceof AuthForbidden || error instanceof AccessError
|
|
60
|
+
|| isOfFamily(names, [AuthForbidden.typeName, AccessError.typeName])) {
|
|
61
|
+
// An established identity that lacks the permission. Re-authenticating changes nothing.
|
|
62
|
+
return FORBIDDEN_ERROR;
|
|
63
|
+
}
|
|
64
|
+
if (error instanceof AuthorizationError || error instanceof AuthFailedError
|
|
65
|
+
|| isOfFamily(names, [AuthorizationError.typeName, AuthFailedError.typeName])) {
|
|
66
|
+
// No usable credential — absent, expired, revoked, or naming a session this server no longer
|
|
67
|
+
// holds. The caller is told to sign in, not that signing in would not help.
|
|
68
|
+
return UNAUTHORIZED_ERROR;
|
|
69
|
+
}
|
|
70
|
+
return declaredErrorStatus(error) ?? SERVER_ERROR;
|
|
71
|
+
};
|
|
72
|
+
const errorExposure = (config) => config?.http?.errors?.exposure === 'development' ? 'development' : 'production';
|
|
73
|
+
/**
|
|
74
|
+
* Preserve a typed/marshalled error when possible without asking `ensure` to convert a plain
|
|
75
|
+
* error. In particular, `ensure` deliberately rethrows SyntaxError; an HTTP boundary still has
|
|
76
|
+
* to serialize it safely and let the incident log retain the original object.
|
|
77
|
+
*/
|
|
78
|
+
const normalizeForWire = (error) => {
|
|
79
|
+
if (error instanceof SyntaxError || isResilientError(error)) {
|
|
80
|
+
return error;
|
|
81
|
+
}
|
|
82
|
+
if (error.message.includes(SEPARATOR)) {
|
|
83
|
+
const ensured = ResilientError.ensure(error);
|
|
84
|
+
// The catch-all converter's legacy constructor shape shifts an ordinary error's fields.
|
|
85
|
+
// Only keep `ensure`'s result when a registered wire prefix actually rebuilt something.
|
|
86
|
+
if (ensured.type !== error.message || ensured.message !== error.stack) {
|
|
87
|
+
return ensured;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
106
90
|
return error;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Answer a thrown error: a status, and the marshalled `ResilientError` as the body.
|
|
181
|
-
*
|
|
182
|
-
* The status is resolved in two steps. The error AS THROWN comes first: it is the one object whose
|
|
183
|
-
* class is certainly the class that was raised, while `ResilientError.ensure` rebuilds through the
|
|
184
|
-
* registry of whichever `@owlmeans/error` copy this module loaded — under duplicate module copies
|
|
185
|
-
* that turns a perfectly recognisable auth refusal into a plain `ResilientError` answering 500.
|
|
186
|
-
* Only when the thrown error answers 500 is the ENSURED error asked, because the rebuild is what
|
|
187
|
-
* gives a status to a marshalled error that crossed a hop as a plain `Error`.
|
|
188
|
-
*/
|
|
189
|
-
export const handleError = (error, reply, exposure = 'production') => {
|
|
190
|
-
if (!reply.sent) {
|
|
191
|
-
const serialized = serializeError(error, exposure);
|
|
192
|
-
applyErrorHeaders(error, reply);
|
|
193
|
-
logFailure(error, reply, serialized.status, serialized.incidentId);
|
|
194
|
-
reply.header(INCIDENT_ID_HEADER, serialized.incidentId)
|
|
195
|
-
.code(serialized.status)
|
|
196
|
-
.send(serialized.body);
|
|
197
|
-
}
|
|
91
|
+
};
|
|
92
|
+
const serializeError = (error, exposure = 'production') => {
|
|
93
|
+
const normalized = normalizeForWire(error);
|
|
94
|
+
const thrown = errorStatus(error);
|
|
95
|
+
const status = thrown !== SERVER_ERROR ? thrown : errorStatus(normalized);
|
|
96
|
+
const incidentId = randomUUID();
|
|
97
|
+
// The server log owns every diagnostic. Production callers receive only its correlation key;
|
|
98
|
+
// development keeps the typed wire form so local clients can retain their usual error details.
|
|
99
|
+
Object.assign(error, { incidentId });
|
|
100
|
+
if (isResilientError(normalized))
|
|
101
|
+
normalized.incidentId = incidentId;
|
|
102
|
+
const body = exposure === 'production'
|
|
103
|
+
? incidentId
|
|
104
|
+
: ResilientError.marshal(normalized, { includeStack: true, incidentId }).message;
|
|
105
|
+
return { status, body, incidentId };
|
|
106
|
+
};
|
|
107
|
+
const applyErrorHeaders = (error, reply) => {
|
|
108
|
+
if (error == null || typeof error !== 'object') {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const retryAfter = error.retryAfter;
|
|
112
|
+
if (typeof retryAfter === 'number' && Number.isFinite(retryAfter) && retryAfter > 0) {
|
|
113
|
+
reply.header('Retry-After', String(Math.ceil(retryAfter)));
|
|
114
|
+
}
|
|
115
|
+
// Match exact registered types. EntitlementRefusal also extends AuthForbidden but is a plan
|
|
116
|
+
// decision, not a person's IAM permission denial.
|
|
117
|
+
const type = error.type;
|
|
118
|
+
if (type === AuthForbidden.typeName || type === AccessError.typeName) {
|
|
119
|
+
reply.header(DENIAL_KIND_HEADER, ACCESS_DENIED_KIND);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const http = logger('http');
|
|
123
|
+
/**
|
|
124
|
+
* The one log entry of a failed request, by what the failure means:
|
|
125
|
+
*
|
|
126
|
+
* | Status | Level | Why |
|
|
127
|
+
* |---|---|---|
|
|
128
|
+
* | 5xx | error | a fault — the one entry that owns type, message and stack, keyed by the incident id |
|
|
129
|
+
* | 403 | warn, `access.forbidden` | an established identity was refused; worth an operator's eye |
|
|
130
|
+
* | 401 | debug, `auth.refused` | an absent or expired credential is the ordinary shape of a sign-in |
|
|
131
|
+
* | other 4xx | debug | the caller's mistake, not the server's |
|
|
132
|
+
*
|
|
133
|
+
* The method and path are logged; the query string is not — it can carry a token.
|
|
134
|
+
*/
|
|
135
|
+
const logFailure = (error, reply, status, incidentId) => {
|
|
136
|
+
const request = reply.request;
|
|
137
|
+
const where = { method: request?.method, path: request?.url?.split('?')[0], status, incidentId };
|
|
138
|
+
if (status >= SERVER_ERROR) {
|
|
139
|
+
http.error('Request failed', { err: error, ...where });
|
|
140
|
+
}
|
|
141
|
+
else if (status === FORBIDDEN_ERROR) {
|
|
142
|
+
http.warn('Access forbidden', { type: error.type, message: error.message, ...where }, { event: 'access.forbidden' });
|
|
143
|
+
}
|
|
144
|
+
else if (status === UNAUTHORIZED_ERROR) {
|
|
145
|
+
http.debug('Authentication refused', { message: error.message, ...where }, { event: 'auth.refused' });
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
http.debug('Request refused', { message: error.message, ...where });
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const handleError = (error, reply, exposure = 'production') => {
|
|
152
|
+
if (!reply.sent) {
|
|
153
|
+
const serialized = serializeError(error, exposure);
|
|
154
|
+
applyErrorHeaders(error, reply);
|
|
155
|
+
logFailure(error, reply, serialized.status, serialized.incidentId);
|
|
156
|
+
reply.header(INCIDENT_ID_HEADER, serialized.incidentId)
|
|
157
|
+
.code(serialized.status)
|
|
158
|
+
.send(serialized.body);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
return { declaredErrorStatus, errorStatus, errorExposure, serializeError, applyErrorHeaders, handleError };
|
|
198
162
|
};
|
|
163
|
+
export const httpErrorHelper = createHttpErrorHelper();
|
|
164
|
+
/** @deprecated compat:factory-refactor — use `httpErrorHelper.errorStatus(…)` */
|
|
165
|
+
export const errorStatus = (error) => httpErrorHelper.errorStatus(error);
|
|
199
166
|
//# sourceMappingURL=error.js.map
|
package/build/utils/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,GAC1F,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIhD
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,GAC1F,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAChH,OA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,IAAI,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,CAAA;AAC5G,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,EAAE,CAAA;AAEtD,iFAAiF;AACjF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/utils/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/utils/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAKnE,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAIvD,eAAO,MAAM,SAAS,GAAU,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,WAC3D,CAAC,UAAU,gBAAgB,CAAC,cAAc,CAAC,OAC/C,cAAc,SAAS,YAAY,KACvC,OAAO,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAmD/C,CAAA"}
|
package/build/utils/guards.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { provideResponse } from '@owlmeans/entrypoint';
|
|
2
|
-
import {
|
|
2
|
+
import { payloadHelper } from './payload.js';
|
|
3
3
|
import { AuthFailedError } from '../errors.js';
|
|
4
|
-
import {
|
|
4
|
+
import { makeEntityScope } from '@owlmeans/auth-common';
|
|
5
5
|
export const authorize = async (context, module, req, reply) => {
|
|
6
6
|
const guards = module.getGuards();
|
|
7
7
|
if (guards.length > 0) {
|
|
8
8
|
const response = provideResponse(reply);
|
|
9
|
-
const request = provideRequest(module.alias, req);
|
|
9
|
+
const request = payloadHelper.provideRequest(module.alias, req);
|
|
10
10
|
let guard = undefined;
|
|
11
11
|
for (const alias of guards) {
|
|
12
12
|
const _guard = context.service(alias);
|
|
13
13
|
if (await _guard.match(request, response)) {
|
|
14
14
|
guard = _guard;
|
|
15
15
|
}
|
|
16
|
-
executeResponse(response, reply, true);
|
|
16
|
+
payloadHelper.executeResponse(response, reply, true);
|
|
17
17
|
if (guard != null) {
|
|
18
18
|
break;
|
|
19
19
|
}
|
|
@@ -25,7 +25,7 @@ export const authorize = async (context, module, req, reply) => {
|
|
|
25
25
|
if (!await guard.handle(request, authResponse)) {
|
|
26
26
|
throw new AuthFailedError(guard.alias);
|
|
27
27
|
}
|
|
28
|
-
executeResponse(authResponse, reply, true);
|
|
28
|
+
payloadHelper.executeResponse(authResponse, reply, true);
|
|
29
29
|
// Guard that returns true and does not provide an error is an optional guard
|
|
30
30
|
// if (authResponse.value == null) {
|
|
31
31
|
// throw SyntaxError(`Guard that returns true and does not provide an error, should provide authorization`)
|
|
@@ -38,7 +38,7 @@ export const authorize = async (context, module, req, reply) => {
|
|
|
38
38
|
// infrastructure names — keys on the entity's stable id. Resolving here, once, is what keeps a
|
|
39
39
|
// rename from being a sweep of every handler: the id arrives on the request, and a slug that
|
|
40
40
|
// has since been retired still resolves to the entity that retired it.
|
|
41
|
-
const entity = await attachEntity(context
|
|
41
|
+
const entity = await makeEntityScope(request).attachEntity(context);
|
|
42
42
|
if (entity != null) {
|
|
43
43
|
// Carried on the raw request the same way `_auth` is, so the request the handler is given
|
|
44
44
|
// later — a different object, built after this runs — sees the same resolution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/utils/guards.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/utils/guards.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,OAAU,EAAE,MAAwC,EACpD,GAAmB,EAAE,KAAmB,EACQ,EAAE;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;IACjC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;QACvC,MAAM,OAAO,GAAG,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAE/D,IAAI,KAAK,GAA6B,SAAS,CAAA;QAC/C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,MAAM,GAAiB,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YACnD,IAAI,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;gBAC1C,KAAK,GAAG,MAAM,CAAA;YAChB,CAAC;YACD,aAAa,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;YACpD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClB,MAAK;YACP,CAAC;QACH,CAAC;QAED,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,MAAM,IAAI,eAAe,EAAE,CAAA;QAC7B,CAAC;QAED,MAAM,YAAY,GAAG,eAAe,CAAO,KAAK,CAAC,CAAA;QACjD,IAAI,CAAC,MAAM,KAAK,CAAC,MAAM,CAAU,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC;QACD,aAAa,CAAC,eAAe,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QACxD,6EAA6E;QAC7E,oCAAoC;QACpC,6GAA6G;QAC7G,IAAI;QACJ,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC;QAClC,IAAI,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,GAAW,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;QACnC,CAAC;QAED,4FAA4F;QAC5F,+FAA+F;QAC/F,6FAA6F;QAC7F,uEAAuE;QACvE,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QACnE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,0FAA0F;YAC1F,gFAAgF;YAChF,CAAC;YAAC,GAAW,CAAC,OAAO,GAAG,MAAM,CAAA;QAChC,CAAC;IACH,CAAC;IACD,mCAAmC;IAClC,GAAW,CAAC,IAAI,GAAG,OAAO,CAAA;IAE3B,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AAC1B,CAAC,CAAA"}
|
package/build/utils/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export * from './error.js';
|
|
2
2
|
export * from './consts.js';
|
|
3
3
|
export type * from './types.js';
|
|
4
|
+
export type * from './error/types.js';
|
|
5
|
+
export type * from './payload/types.js';
|
|
6
|
+
export type * from './context/types.js';
|
|
4
7
|
export * from './server.js';
|
|
5
8
|
export * from './payload.js';
|
|
6
|
-
export * from './
|
|
9
|
+
export * from './schema.js';
|
|
7
10
|
export * from './guards.js';
|
|
8
11
|
export * from './context.js';
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,kBAAkB,CAAA;AACrC,mBAAmB,oBAAoB,CAAA;AACvC,mBAAmB,oBAAoB,CAAA;AACvC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
|
package/build/utils/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export * from './error.js';
|
|
|
2
2
|
export * from './consts.js';
|
|
3
3
|
export * from './server.js';
|
|
4
4
|
export * from './payload.js';
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './schema.js';
|
|
6
6
|
export * from './guards.js';
|
|
7
7
|
export * from './context.js';
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/build/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAK3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint';
|
|
2
|
+
import type { Request, Response } from '../../types.js';
|
|
3
|
+
/** Moves an exchange between Fastify and the entrypoint shapes: the request in, the response out. */
|
|
4
|
+
export interface PayloadHelper {
|
|
5
|
+
/** The entrypoint request of a Fastify request; `provision` keeps the original on it. */
|
|
6
|
+
provideRequest: (alias: string, req: Request, provision?: boolean) => AbstractRequest;
|
|
7
|
+
/**
|
|
8
|
+
* Emits the response onto the fastify reply if the handler produced an
|
|
9
|
+
* error or an outcome. Returns `true` when something was actually sent so
|
|
10
|
+
* callers don't rely on `reply.sent`, which in fastify v5 only flips once
|
|
11
|
+
* the raw socket finishes writing (asynchronously) and therefore reads
|
|
12
|
+
* `false` synchronously right after `reply.send()`.
|
|
13
|
+
*
|
|
14
|
+
* @throws {Error}
|
|
15
|
+
*/
|
|
16
|
+
executeResponse: <T>(response: AbstractResponse<T>, reply: Response, throwOnError?: boolean) => boolean;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/payload/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEvD,qGAAqG;AACrG,MAAM,WAAW,aAAa;IAC5B,yFAAyF;IACzF,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,eAAe,CAAA;IACrF;;;;;;;;OAQG;IACH,eAAe,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,OAAO,KAAK,OAAO,CAAA;CACxG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/payload/types.ts"],"names":[],"mappings":""}
|
package/build/utils/payload.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare const provideRequest: (alias: string, req: Request, provision?: boolean) => AbstractRequest;
|
|
5
|
-
/**
|
|
6
|
-
* Emits the response onto the fastify reply if the handler produced an
|
|
7
|
-
* error or an outcome. Returns `true` when something was actually sent so
|
|
8
|
-
* callers don't rely on `reply.sent`, which in fastify v5 only flips once
|
|
9
|
-
* the raw socket finishes writing (asynchronously) and therefore reads
|
|
10
|
-
* `false` synchronously right after `reply.send()`.
|
|
11
|
-
*
|
|
12
|
-
* @throws {Error}
|
|
13
|
-
*/
|
|
14
|
-
export declare const executeResponse: <T>(response: AbstractResponse<T>, reply: Response, throwOnError?: boolean) => boolean;
|
|
15
|
-
export declare const fixFormatDates: (schema: AnySchemaObject) => AnySchemaObject;
|
|
1
|
+
import type { PayloadHelper } from './payload/types.js';
|
|
2
|
+
export declare const createPayloadHelper: () => PayloadHelper;
|
|
3
|
+
export declare const payloadHelper: PayloadHelper;
|
|
16
4
|
//# sourceMappingURL=payload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/utils/payload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/utils/payload.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,eAAO,MAAM,mBAAmB,QAAO,aA4CtC,CAAA;AAED,eAAO,MAAM,aAAa,eAAwB,CAAA"}
|