@samebase/alchemy-convex 0.14.0 → 0.14.1
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/package.json +1 -1
- package/src/store/functions.ts +8 -6
package/package.json
CHANGED
package/src/store/functions.ts
CHANGED
|
@@ -193,20 +193,22 @@ export const readerFunctions = (alchemyState: ComponentApi) => ({
|
|
|
193
193
|
returns: repositoryReply,
|
|
194
194
|
handler: async (ctx) => {
|
|
195
195
|
const identity = await ctx.auth.getUserIdentity();
|
|
196
|
+
// Custom claims are bracket reads: a base app compiles this file under its own tsconfig,
|
|
197
|
+
// which can set noPropertyAccessFromIndexSignature.
|
|
198
|
+
const scope = identity?.["scope"];
|
|
199
|
+
const repository = identity?.["repository"];
|
|
196
200
|
// Only a token of the deployment's own issuer reads, the one that `authorize` signs: a base
|
|
197
201
|
// can accept other providers too, and a token of one of those with the same claims does not.
|
|
198
202
|
if (
|
|
199
203
|
identity === null ||
|
|
200
204
|
identity.issuer !== env.CONVEX_CLOUD_URL ||
|
|
201
|
-
|
|
202
|
-
typeof
|
|
203
|
-
!repositoryName.test(
|
|
205
|
+
scope !== "alchemy:read" ||
|
|
206
|
+
typeof repository !== "string" ||
|
|
207
|
+
!repositoryName.test(repository)
|
|
204
208
|
) {
|
|
205
209
|
throw new Error("Alchemy repository read access is required.");
|
|
206
210
|
}
|
|
207
|
-
return await ctx.runQuery(alchemyState.reader.repository, {
|
|
208
|
-
repository: identity.repository,
|
|
209
|
-
});
|
|
211
|
+
return await ctx.runQuery(alchemyState.reader.repository, { repository });
|
|
210
212
|
},
|
|
211
213
|
}),
|
|
212
214
|
});
|