diff --git a/packages/interface/src/capability.ts b/packages/interface/src/capability.ts index ab9fde43..d35f5b72 100644 --- a/packages/interface/src/capability.ts +++ b/packages/interface/src/capability.ts @@ -335,10 +335,6 @@ export interface ParsedCapability< nb: C } -export type InferCaveats = Optionalize<{ - [K in keyof C]: C[K] extends Reader ? T : never -}> - export interface Descriptor< A extends Ability, R extends URI, diff --git a/packages/server/src/api.ts b/packages/server/src/api.ts index 40287dad..6b027ccf 100644 --- a/packages/server/src/api.ts +++ b/packages/server/src/api.ts @@ -1,5 +1,5 @@ import * as API from '@ucanto/interface' -import { InferCaveats, CanIssue, ParsedCapability } from '@ucanto/interface' +import { CanIssue, ParsedCapability } from '@ucanto/interface' export * from '@ucanto/interface' @@ -23,8 +23,8 @@ export interface ProviderContext< R extends API.URI = API.URI, C extends API.Caveats = API.Caveats > { - capability: API.ParsedCapability> - invocation: API.Invocation>> + capability: API.ParsedCapability + invocation: API.Invocation> context: API.InvocationContext } diff --git a/packages/server/src/handler.js b/packages/server/src/handler.js index 5f1bcbf3..b0a1d945 100644 --- a/packages/server/src/handler.js +++ b/packages/server/src/handler.js @@ -6,15 +6,15 @@ import { access } from '@ucanto/validator' * @template {API.URI} R * @template {API.Caveats} C * @template {unknown} U - * @param {API.CapabilityParser>>>} capability - * @param {(input:API.ProviderInput>>) => API.Await} handler - * @returns {API.ServiceMethod>, Exclude, Exclude>>} + * @param {API.CapabilityParser>>} capability + * @param {(input:API.ProviderInput>) => API.Await} handler + * @returns {API.ServiceMethod, Exclude, Exclude>>} */ export const provide = (capability, handler) => /** - * @param {API.Invocation>>} invocation + * @param {API.Invocation>} invocation * @param {API.InvocationContext} options */ async (invocation, options) => { diff --git a/packages/server/test/server.spec.js b/packages/server/test/server.spec.js index b2bd53cb..cf518dac 100644 --- a/packages/server/test/server.spec.js +++ b/packages/server/test/server.spec.js @@ -5,13 +5,14 @@ import * as CBOR from '@ucanto/transport/cbor' import { alice, bob, mallory, service as w3 } from './fixtures.js' import * as Service from '../../client/test/service.js' import { test, assert } from './test.js' +import { Schema } from '@ucanto/validator' const storeAdd = Server.capability({ can: 'store/add', with: Server.URI.match({ protocol: 'did:' }), - nb: { + nb: Schema.struct({ link: Server.Link.match().optional(), - }, + }), derives: (claimed, delegated) => { if (claimed.with !== delegated.with) { return new Server.Failure( @@ -34,9 +35,9 @@ const storeAdd = Server.capability({ const storeRemove = Server.capability({ can: 'store/remove', with: Server.URI.match({ protocol: 'did:' }), - nb: { + nb: Schema.struct({ link: Server.Link.match().optional(), - }, + }), derives: (claimed, delegated) => { if (claimed.with !== delegated.with) { return new Server.Failure( diff --git a/packages/server/test/service/store.js b/packages/server/test/service/store.js index 75f8c5d4..e67f0f15 100644 --- a/packages/server/test/service/store.js +++ b/packages/server/test/service/store.js @@ -4,13 +4,14 @@ import { provide } from '../../src/handler.js' import * as API from './api.js' import * as Access from './access.js' import { service as issuer } from '../fixtures.js' +import { Schema } from '@ucanto/validator/src/lib.js' const addCapability = Server.capability({ can: 'store/add', with: Server.URI.match({ protocol: 'did:' }), - nb: { + nb: Schema.struct({ link: Server.Link.match().optional(), - }, + }), derives: (claimed, delegated) => { if (claimed.with !== delegated.with) { return new Server.Failure( @@ -34,9 +35,9 @@ const addCapability = Server.capability({ const removeCapability = Server.capability({ can: 'store/remove', with: Server.URI.match({ protocol: 'did:' }), - nb: { + nb: Schema.struct({ link: Server.Link.match().optional(), - }, + }), derives: (claimed, delegated) => { if (claimed.with !== delegated.with) { return new Server.Failure(