feat: add typed ESI transport extensions
This commit is contained in:
@@ -162,6 +162,33 @@ describe("Convex persistence", () => {
|
||||
})).rejects.toThrow("not eligible");
|
||||
});
|
||||
|
||||
test("asset lease binds refreshed authority revisions, scopes, and credential version", async () => {
|
||||
const t = convexTest({ schema, modules });
|
||||
const account = await login(t, { characterId: 122, sessionHash: "authority-session", ownerHash: "authority-owner" });
|
||||
const committed = await t.mutation(mutation("bridgeSaveTokens"), {
|
||||
...bridge, userId: account.userId, characterId: 122,
|
||||
encryptedTokens: "refreshed", tokenExpiresAt: Date.now() + 60_000,
|
||||
scopes: ["esi-assets.read_assets.v1"], expectedVersion: 1, returnAuthority: true,
|
||||
});
|
||||
expect(committed).toMatchObject({ saved: true, credentialVersion: 2, grantRevision: 1, authorizationEpoch: 1 });
|
||||
await expect(t.mutation(mutation("bridgeBeginSync"), {
|
||||
...bridge, userId: account.userId, characterId: 122,
|
||||
expectedScopes: ["esi-assets.read_assets.v1"], expectedGrantRevision: 999,
|
||||
expectedAuthorizationEpoch: 1, expectedCredentialVersion: 2,
|
||||
})).rejects.toThrow("authorization changed before lease");
|
||||
await expect(t.mutation(mutation("bridgeBeginSync"), {
|
||||
...bridge, userId: account.userId, characterId: 122,
|
||||
expectedScopes: ["other.scope"], expectedGrantRevision: 1,
|
||||
expectedAuthorizationEpoch: 1, expectedCredentialVersion: 2,
|
||||
})).rejects.toThrow("scopes changed before lease");
|
||||
const generation = await t.mutation(mutation("bridgeBeginSync"), {
|
||||
...bridge, userId: account.userId, characterId: 122,
|
||||
expectedScopes: ["esi-assets.read_assets.v1"], expectedGrantRevision: 1,
|
||||
expectedAuthorizationEpoch: 1, expectedCredentialVersion: 2,
|
||||
});
|
||||
expect(generation).toEqual(expect.any(String));
|
||||
});
|
||||
|
||||
test("OAuth state is one-time and token writes use CAS", async () => {
|
||||
const t = convexTest({ schema, modules });
|
||||
await expect(
|
||||
|
||||
Reference in New Issue
Block a user