@ampless/backend 0.2.0-alpha.12 → 0.2.0-alpha.14
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/dist/functions/mcp-handler.js +14 -5
- package/dist/index.d.ts +9 -1
- package/package.json +1 -1
|
@@ -627,17 +627,26 @@ async function validateBearer(plaintext) {
|
|
|
627
627
|
);
|
|
628
628
|
const row = res.Item;
|
|
629
629
|
if (!row?.value) return null;
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
} catch {
|
|
634
|
-
console.error("[mcp-handler] could not parse token row", { hash });
|
|
630
|
+
const meta = decodeTokenMeta(row.value);
|
|
631
|
+
if (!meta) {
|
|
632
|
+
console.error("[mcp-handler] could not decode token row", { hash, valueType: typeof row.value });
|
|
635
633
|
return null;
|
|
636
634
|
}
|
|
637
635
|
if (meta.revokedAt) return null;
|
|
638
636
|
if (meta.expiresAt && new Date(meta.expiresAt).getTime() <= Date.now()) return null;
|
|
639
637
|
return meta;
|
|
640
638
|
}
|
|
639
|
+
function decodeTokenMeta(value) {
|
|
640
|
+
if (typeof value === "object") return value;
|
|
641
|
+
if (typeof value === "string") {
|
|
642
|
+
try {
|
|
643
|
+
return JSON.parse(value);
|
|
644
|
+
} catch {
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
641
650
|
var cachedCtx = null;
|
|
642
651
|
function makeContext(meta) {
|
|
643
652
|
if (cachedCtx && cachedCtx.defaultSiteId === (meta.scope.siteId ?? "default")) {
|
package/dist/index.d.ts
CHANGED
|
@@ -217,6 +217,14 @@ interface AmplessSchemaAuthorizationOpts {
|
|
|
217
217
|
* `amplify/data/resource.ts`. When no Lambda function refs are
|
|
218
218
|
* supplied the function returns `[]`, so the schema stays unaffected.
|
|
219
219
|
*
|
|
220
|
+
* Return type is `any[]` (matching the rest of this module's
|
|
221
|
+
* intentional looseness around `@aws-amplify/data-schema`'s heavily
|
|
222
|
+
* generic builder types) so callers don't have to wrestle the
|
|
223
|
+
* generic `SchemaAuthorization<…>` parameters that change between
|
|
224
|
+
* minor versions. `amplify/data/resource.ts` strict-type-checks fine
|
|
225
|
+
* downstream because the schema itself still resolves through
|
|
226
|
+
* `ClientSchema<typeof schema>` correctly.
|
|
227
|
+
*
|
|
220
228
|
* Usage:
|
|
221
229
|
*
|
|
222
230
|
* const schema = a.schema({
|
|
@@ -226,7 +234,7 @@ interface AmplessSchemaAuthorizationOpts {
|
|
|
226
234
|
* mcpHandlerFunction: mcpHandler,
|
|
227
235
|
* }))
|
|
228
236
|
*/
|
|
229
|
-
declare function amplessSchemaAuthorization(allow: any, opts?: AmplessSchemaAuthorizationOpts):
|
|
237
|
+
declare function amplessSchemaAuthorization(allow: any, opts?: AmplessSchemaAuthorizationOpts): any[];
|
|
230
238
|
/**
|
|
231
239
|
* Standard authorization modes for ampless. `userPool` is the default
|
|
232
240
|
* (admin/editor access); the API key serves the public read endpoints
|
package/package.json
CHANGED