@totemsdk/omnia-lsp-provider 0.1.0 → 0.2.0

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/cjs/host.js CHANGED
@@ -6,6 +6,12 @@ function handlerFor(methods, name) {
6
6
  ? methods.get(name)
7
7
  : undefined;
8
8
  }
9
+ function isRecord(value) {
10
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
11
+ }
12
+ function text(value) {
13
+ return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
14
+ }
9
15
  /**
10
16
  * Adapt an `omnia-host` method registry (`createHostMethods(context)`) to the
11
17
  * LSP provider host port.
@@ -50,12 +56,35 @@ function createOmniaHostProviderHost(options) {
50
56
  ...(contestDelayBlocks !== undefined ? { contestDelayBlocks } : {}),
51
57
  operationId: `${prefix}-open-${quote.quoteId}`,
52
58
  }));
59
+ // OMN-070: require explicit, operation-specific evidence. An undefined,
60
+ // non-object, `{}` or error-only response is a failure, and success
61
+ // without a channelId is not a successful open.
62
+ if (!isRecord(result)) {
63
+ return {
64
+ success: false,
65
+ error: `${openMethod} returned no structured result`,
66
+ errorCode: 'HOST_PROTOCOL_ERROR',
67
+ };
68
+ }
69
+ const channelId = text(result.channelId);
70
+ if (result.success !== true) {
71
+ return {
72
+ success: false,
73
+ error: text(result.error) ?? `${openMethod} reported failure`,
74
+ errorCode: text(result.errorCode) ?? 'HOST_OPEN_FAILED',
75
+ };
76
+ }
77
+ if (!channelId) {
78
+ return {
79
+ success: false,
80
+ error: `${openMethod} reported success without a channelId`,
81
+ errorCode: 'HOST_PROTOCOL_ERROR',
82
+ };
83
+ }
53
84
  return {
54
- success: result?.success !== false,
55
- ...(result?.channelId ? { channelId: result.channelId } : {}),
56
- ...(result?.fundingTxId ? { fundingTxId: result.fundingTxId } : {}),
57
- ...(result?.error ? { error: result.error } : {}),
58
- ...(result?.errorCode ? { errorCode: result.errorCode } : {}),
85
+ success: true,
86
+ channelId,
87
+ ...(text(result.fundingTxId) ? { fundingTxId: text(result.fundingTxId) } : {}),
59
88
  };
60
89
  }
61
90
  catch (error) {
@@ -80,11 +109,19 @@ function createOmniaHostProviderHost(options) {
80
109
  channelId,
81
110
  operationId: `${prefix}-close-${channelId}`,
82
111
  }));
83
- return {
84
- success: result?.success !== false,
85
- ...(result?.error ? { error: result.error } : {}),
86
- ...(result?.errorCode ? { errorCode: result.errorCode } : {}),
87
- };
112
+ // OMN-070: an undefined or malformed close response is not a success.
113
+ if (!isRecord(result) || result.success !== true) {
114
+ return {
115
+ success: false,
116
+ error: isRecord(result) && text(result.error)
117
+ ? text(result.error)
118
+ : `${closeMethod} did not confirm the close`,
119
+ errorCode: isRecord(result) && text(result.errorCode)
120
+ ? text(result.errorCode)
121
+ : 'HOST_CLOSE_FAILED',
122
+ };
123
+ }
124
+ return { success: true };
88
125
  }
89
126
  catch (error) {
90
127
  return {
@@ -3,6 +3,8 @@ export type { OmniaLspOpenDecision, OmniaLspOpenRequest, OmniaLspProviderPolicy,
3
3
  export { createUnsignedOpenQuote, signOpenQuote, } from './quote.js';
4
4
  export type { CreateQuoteOptions, UnsignedOmniaLspOpenQuote, } from './quote.js';
5
5
  export { createOmniaLspProvider, } from './provider.js';
6
- export type { OmniaLspHostCloseResult, OmniaLspHostOpenInput, OmniaLspHostOpenResult, OmniaLspProvider, OmniaLspProviderConfig, OmniaLspProviderHost, } from './provider.js';
6
+ export type { OmniaLspConsumerIdentity, OmniaLspHostCloseResult, OmniaLspHostOpenInput, OmniaLspHostOpenResult, OmniaLspOpenQuoteOptions, OmniaLspProvider, OmniaLspProviderConfig, OmniaLspProviderHost, } from './provider.js';
7
+ export { createMemoryQuoteLedger } from './ledger.js';
8
+ export type { ConsumeReservationResult, OmniaLspQuoteLedger, OmniaLspQuoteReservation, QuoteReservationState, } from './ledger.js';
7
9
  export { createOmniaHostProviderHost } from './host.js';
8
10
  export type { CreateOmniaHostProviderHostOptions, OmniaHostHandler, OmniaHostMethodMap, } from './host.js';
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createOmniaHostProviderHost = exports.createOmniaLspProvider = exports.signOpenQuote = exports.createUnsignedOpenQuote = exports.evaluateOpenRequest = void 0;
3
+ exports.createOmniaHostProviderHost = exports.createMemoryQuoteLedger = exports.createOmniaLspProvider = exports.signOpenQuote = exports.createUnsignedOpenQuote = exports.evaluateOpenRequest = void 0;
4
4
  var policy_js_1 = require("./policy.js");
5
5
  Object.defineProperty(exports, "evaluateOpenRequest", { enumerable: true, get: function () { return policy_js_1.evaluateOpenRequest; } });
6
6
  var quote_js_1 = require("./quote.js");
@@ -8,5 +8,7 @@ Object.defineProperty(exports, "createUnsignedOpenQuote", { enumerable: true, ge
8
8
  Object.defineProperty(exports, "signOpenQuote", { enumerable: true, get: function () { return quote_js_1.signOpenQuote; } });
9
9
  var provider_js_1 = require("./provider.js");
10
10
  Object.defineProperty(exports, "createOmniaLspProvider", { enumerable: true, get: function () { return provider_js_1.createOmniaLspProvider; } });
11
+ var ledger_js_1 = require("./ledger.js");
12
+ Object.defineProperty(exports, "createMemoryQuoteLedger", { enumerable: true, get: function () { return ledger_js_1.createMemoryQuoteLedger; } });
11
13
  var host_js_1 = require("./host.js");
12
14
  Object.defineProperty(exports, "createOmniaHostProviderHost", { enumerable: true, get: function () { return host_js_1.createOmniaHostProviderHost; } });
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Quote reservations (OMN-068).
3
+ *
4
+ * Admission validates a request against the manifest's advertised capacity, but
5
+ * the manifest is static: without a ledger, N concurrent quotes each fit inside
6
+ * capacity while their sum does not. The facade now reserves the provider-side
7
+ * amount when it issues a quote, releases it on expiry or a failed open, and
8
+ * consumes it atomically when a quote is redeemed.
9
+ *
10
+ * The in-memory ledger is the default. A production provider injects an
11
+ * implementation backed by durable storage; the interface is intentionally
12
+ * small so that the durable version can make `consume` a single transaction.
13
+ */
14
+ export type QuoteReservationState = 'reserved' | 'consumed' | 'released';
15
+ export interface OmniaLspQuoteReservation {
16
+ quoteId: string;
17
+ providerId: string;
18
+ tokenId: string;
19
+ /** Provider-side amount as quoted, decimal units. */
20
+ amount: string;
21
+ /** Provider-side amount in integer units (18 decimal places). */
22
+ amountUnits: bigint;
23
+ expiresAt: number;
24
+ state: QuoteReservationState;
25
+ updatedAt: number;
26
+ }
27
+ export type ConsumeReservationResult =
28
+ /** The reservation existed, was live, and is now consumed. */
29
+ 'consumed'
30
+ /** No reservation with this id was ever recorded. */
31
+ | 'unknown'
32
+ /** The reservation exists but its TTL has passed. */
33
+ | 'expired'
34
+ /** The reservation was already consumed or released. */
35
+ | 'already-consumed';
36
+ export interface OmniaLspQuoteLedger {
37
+ /** Record a reservation. Throws if the quoteId is already known. */
38
+ reserve(entry: OmniaLspQuoteReservation): Promise<void> | void;
39
+ /**
40
+ * Atomically move a live reservation to consumed. `unknown` must be returned
41
+ * when this ledger has no record, never an implicit success.
42
+ */
43
+ consume(quoteId: string, now?: number): Promise<ConsumeReservationResult> | ConsumeReservationResult;
44
+ /** Free a reservation. No-op when unknown or already final. */
45
+ release(quoteId: string, now?: number): Promise<void> | void;
46
+ /** Sum of live reservations for a token and provider, in integer units. */
47
+ outstanding(tokenId: string, providerId: string, now?: number): Promise<bigint> | bigint;
48
+ /** Optional: drop final or expired entries. */
49
+ prune?(now?: number): Promise<void> | void;
50
+ }
51
+ /**
52
+ * Default in-process ledger.
53
+ *
54
+ * Single-threaded JS makes the check-and-set inside `consume` atomic for one
55
+ * process. It does not survive a restart — inject a durable ledger for that.
56
+ */
57
+ export declare function createMemoryQuoteLedger(): OmniaLspQuoteLedger;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ /**
3
+ * Quote reservations (OMN-068).
4
+ *
5
+ * Admission validates a request against the manifest's advertised capacity, but
6
+ * the manifest is static: without a ledger, N concurrent quotes each fit inside
7
+ * capacity while their sum does not. The facade now reserves the provider-side
8
+ * amount when it issues a quote, releases it on expiry or a failed open, and
9
+ * consumes it atomically when a quote is redeemed.
10
+ *
11
+ * The in-memory ledger is the default. A production provider injects an
12
+ * implementation backed by durable storage; the interface is intentionally
13
+ * small so that the durable version can make `consume` a single transaction.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.createMemoryQuoteLedger = createMemoryQuoteLedger;
17
+ /**
18
+ * Default in-process ledger.
19
+ *
20
+ * Single-threaded JS makes the check-and-set inside `consume` atomic for one
21
+ * process. It does not survive a restart — inject a durable ledger for that.
22
+ */
23
+ function createMemoryQuoteLedger() {
24
+ const entries = new Map();
25
+ return {
26
+ reserve(entry) {
27
+ if (entries.has(entry.quoteId)) {
28
+ throw new Error(`quote ${entry.quoteId} is already reserved`);
29
+ }
30
+ entries.set(entry.quoteId, { ...entry });
31
+ },
32
+ consume(quoteId, now = Date.now()) {
33
+ const entry = entries.get(quoteId);
34
+ if (!entry)
35
+ return 'unknown';
36
+ if (entry.state !== 'reserved')
37
+ return 'already-consumed';
38
+ if (entry.expiresAt <= now)
39
+ return 'expired';
40
+ entry.state = 'consumed';
41
+ entry.updatedAt = now;
42
+ return 'consumed';
43
+ },
44
+ release(quoteId, now = Date.now()) {
45
+ const entry = entries.get(quoteId);
46
+ if (!entry || entry.state !== 'reserved')
47
+ return;
48
+ entry.state = 'released';
49
+ entry.updatedAt = now;
50
+ },
51
+ outstanding(tokenId, providerId, now = Date.now()) {
52
+ let total = 0n;
53
+ for (const entry of entries.values()) {
54
+ if (entry.state !== 'reserved')
55
+ continue;
56
+ if (entry.expiresAt <= now)
57
+ continue;
58
+ if (entry.tokenId !== tokenId)
59
+ continue;
60
+ if (entry.providerId !== providerId)
61
+ continue;
62
+ total += entry.amountUnits;
63
+ }
64
+ return total;
65
+ },
66
+ prune(now = Date.now()) {
67
+ for (const [id, entry] of entries) {
68
+ if (entry.state !== 'reserved' || entry.expiresAt <= now)
69
+ entries.delete(id);
70
+ }
71
+ },
72
+ };
73
+ }
@@ -16,8 +16,13 @@ export interface OmniaLspOpenRequest {
16
16
  direction: OmniaLspDirection;
17
17
  lease?: boolean;
18
18
  jit?: boolean;
19
+ /** Reject when the total open fee exceeds this decimal amount. */
20
+ maxOpenFee?: string;
21
+ /**
22
+ * Legacy ceiling for the percentage component. Also bounds a flat fee by
23
+ * converting it to the equivalent basis points on the fee basis (OMN-072).
24
+ */
19
25
  maxOpenFeeBps?: number;
20
- now?: number;
21
26
  }
22
27
  export interface OmniaLspOpenDecision {
23
28
  allowed: boolean;
@@ -29,11 +34,23 @@ export interface OmniaLspProviderPolicy {
29
34
  requireNonCustodial?: boolean;
30
35
  /** Minimum provider-bond score accepted by this provider. Informational only. */
31
36
  minProviderScore?: number;
37
+ /**
38
+ * Spendable provider funds for the requested asset, decimal units. When set,
39
+ * the provider-side contribution must fit inside it (OMN-067).
40
+ */
41
+ availableProviderFunds?: string;
32
42
  }
43
+ declare function hasCapacity(asset: OmniaLspAsset, direction: OmniaLspDirection, amount: bigint): boolean;
33
44
  /**
34
45
  * Evaluate an open request against a provider manifest.
35
46
  *
36
47
  * This is the provider's admission policy. It does not reserve capacity; the
37
- * provider MUST re-check capacity and channel state before co-signing.
48
+ * provider MUST do that through the quote ledger (OMN-068).
49
+ *
50
+ * Both sides of the channel are validated independently (OMN-067): the
51
+ * consumer's `localAmount` and the provider's own `remoteAmount`, because the
52
+ * provider is the party that funds the latter. `now` is the provider's trusted
53
+ * clock — never the requester's (OMN-069).
38
54
  */
39
- export declare function evaluateOpenRequest(manifest: OmniaLspManifest, request: OmniaLspOpenRequest, policy?: OmniaLspProviderPolicy): OmniaLspOpenDecision;
55
+ export declare function evaluateOpenRequest(manifest: OmniaLspManifest, request: OmniaLspOpenRequest, policy?: OmniaLspProviderPolicy, now?: number): OmniaLspOpenDecision;
56
+ export { hasCapacity };
@@ -1,32 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.evaluateOpenRequest = evaluateOpenRequest;
4
- const DECIMAL_SCALE = 18n;
5
- const DECIMAL_FACTOR = 10n ** DECIMAL_SCALE;
6
- function decimalKey(value) {
7
- const [whole = '0', fraction = ''] = value.split('.');
8
- return (BigInt(whole) * DECIMAL_FACTOR +
9
- BigInt(fraction.padEnd(Number(DECIMAL_SCALE), '0').slice(0, Number(DECIMAL_SCALE))));
10
- }
11
- function gte(a, b) {
12
- return decimalKey(a) >= decimalKey(b);
13
- }
4
+ exports.hasCapacity = hasCapacity;
5
+ const omnia_lsp_1 = require("@totemsdk/omnia-lsp");
14
6
  function hasCapacity(asset, direction, amount) {
15
7
  if (direction === 'send')
16
- return gte(asset.outboundCapacity, amount);
8
+ return parseUnitsAtLeast(asset.outboundCapacity, amount);
17
9
  if (direction === 'receive')
18
- return gte(asset.inboundCapacity, amount);
19
- return gte(asset.inboundCapacity, amount) && gte(asset.outboundCapacity, amount);
10
+ return parseUnitsAtLeast(asset.inboundCapacity, amount);
11
+ return parseUnitsAtLeast(asset.inboundCapacity, amount) && parseUnitsAtLeast(asset.outboundCapacity, amount);
12
+ }
13
+ /** True when `capacity` (decimal) is at least `amount` (units). */
14
+ function parseUnitsAtLeast(capacity, amount) {
15
+ const parsed = (0, omnia_lsp_1.parseDecimalUnits)(capacity, { allowZero: true });
16
+ return parsed.ok && parsed.units >= amount;
17
+ }
18
+ /** The capacity side the provider itself draws on for a direction. */
19
+ function providerCapacitySide(direction) {
20
+ return direction === 'send' ? 'outbound' : direction === 'receive' ? 'inbound' : 'both';
21
+ }
22
+ /** The capacity side the consumer's contribution lands on. */
23
+ function consumerCapacitySide(direction) {
24
+ return direction === 'send' ? 'inbound' : direction === 'receive' ? 'outbound' : 'both';
25
+ }
26
+ function withinCapacity(asset, side, amount) {
27
+ if (side === 'both') {
28
+ return parseUnitsAtLeast(asset.inboundCapacity, amount) && parseUnitsAtLeast(asset.outboundCapacity, amount);
29
+ }
30
+ return parseUnitsAtLeast(side === 'inbound' ? asset.inboundCapacity : asset.outboundCapacity, amount);
20
31
  }
21
32
  /**
22
33
  * Evaluate an open request against a provider manifest.
23
34
  *
24
35
  * This is the provider's admission policy. It does not reserve capacity; the
25
- * provider MUST re-check capacity and channel state before co-signing.
36
+ * provider MUST do that through the quote ledger (OMN-068).
37
+ *
38
+ * Both sides of the channel are validated independently (OMN-067): the
39
+ * consumer's `localAmount` and the provider's own `remoteAmount`, because the
40
+ * provider is the party that funds the latter. `now` is the provider's trusted
41
+ * clock — never the requester's (OMN-069).
26
42
  */
27
- function evaluateOpenRequest(manifest, request, policy = {}) {
43
+ function evaluateOpenRequest(manifest, request, policy = {}, now = Date.now()) {
28
44
  const errors = [];
29
- const now = request.now ?? Date.now();
30
45
  if (request.providerId !== manifest.providerId) {
31
46
  errors.push('request.providerId does not match the manifest');
32
47
  }
@@ -41,14 +56,72 @@ function evaluateOpenRequest(manifest, request, policy = {}) {
41
56
  errors.push('asset is not offered by the provider');
42
57
  }
43
58
  else {
44
- if (!gte(request.localAmount, asset.minChannel)) {
45
- errors.push('localAmount is below the provider minimum');
59
+ const local = (0, omnia_lsp_1.parseDecimalUnits)(request.localAmount);
60
+ const remote = (0, omnia_lsp_1.parseDecimalUnits)(request.remoteAmount);
61
+ const minChannel = (0, omnia_lsp_1.parseDecimalUnits)(asset.minChannel, { allowZero: true });
62
+ const maxChannel = (0, omnia_lsp_1.parseDecimalUnits)(asset.maxChannel, { allowZero: true });
63
+ if (!local.ok)
64
+ errors.push(`localAmount: ${local.error}`);
65
+ if (!remote.ok)
66
+ errors.push(`remoteAmount: ${remote.error}`);
67
+ if (!minChannel.ok)
68
+ errors.push(`manifest asset minChannel: ${minChannel.error}`);
69
+ if (!maxChannel.ok)
70
+ errors.push(`manifest asset maxChannel: ${maxChannel.error}`);
71
+ if (local.ok && minChannel.ok && maxChannel.ok) {
72
+ if (local.units < minChannel.units)
73
+ errors.push('localAmount is below the provider minimum');
74
+ if (local.units > maxChannel.units)
75
+ errors.push('localAmount is above the provider maximum');
76
+ }
77
+ if (remote.ok && minChannel.ok && maxChannel.ok) {
78
+ // OMN-067: the provider's own contribution is a channel limit too.
79
+ if (remote.units < minChannel.units)
80
+ errors.push('remoteAmount is below the provider minimum');
81
+ if (remote.units > maxChannel.units)
82
+ errors.push('remoteAmount is above the provider maximum');
46
83
  }
47
- if (!gte(asset.maxChannel, request.localAmount)) {
48
- errors.push('localAmount is above the provider maximum');
84
+ if (local.ok && !withinCapacity(asset, consumerCapacitySide(request.direction), local.units)) {
85
+ errors.push('insufficient capacity for the consumer contribution in the requested direction');
49
86
  }
50
- if (!hasCapacity(asset, request.direction, request.localAmount)) {
51
- errors.push('insufficient capacity for the requested direction');
87
+ if (remote.ok && !withinCapacity(asset, providerCapacitySide(request.direction), remote.units)) {
88
+ errors.push('insufficient capacity for the provider contribution in the requested direction');
89
+ }
90
+ if (remote.ok && policy.availableProviderFunds !== undefined) {
91
+ const available = (0, omnia_lsp_1.parseDecimalUnits)(policy.availableProviderFunds, { allowZero: true });
92
+ if (!available.ok) {
93
+ errors.push(`availableProviderFunds: ${available.error}`);
94
+ }
95
+ else if (remote.units > available.units) {
96
+ errors.push('provider-side amount exceeds the provider available funds');
97
+ }
98
+ }
99
+ if (local.ok && remote.ok) {
100
+ const fees = (0, omnia_lsp_1.computeOpenFees)(manifest, request, omnia_lsp_1.DEFAULT_FEE_BASIS);
101
+ if (!fees.ok) {
102
+ errors.push(`fee schedule: ${fees.error}`);
103
+ }
104
+ else {
105
+ const schedule = fees.schedule;
106
+ if (request.maxOpenFee !== undefined) {
107
+ const ceiling = (0, omnia_lsp_1.parseDecimalUnits)(request.maxOpenFee, { allowZero: true });
108
+ if (!ceiling.ok) {
109
+ errors.push(`maxOpenFee: ${ceiling.error}`);
110
+ }
111
+ else if (schedule.totalFeeUnits > ceiling.units) {
112
+ errors.push('provider total open fee exceeds the request maximum');
113
+ }
114
+ }
115
+ if (request.maxOpenFeeBps !== undefined) {
116
+ // A flat fee is bounded by converting the ceiling onto the fee basis,
117
+ // so a manifest with openFlat can no longer bypass the check (OMN-072).
118
+ const basis = (0, omnia_lsp_1.parseDecimalUnits)(schedule.basisAmount, { allowZero: true });
119
+ const bpsCeiling = basis.ok ? (0, omnia_lsp_1.applyBpsUnits)(basis.units, request.maxOpenFeeBps) : 0n;
120
+ if (schedule.openFeeUnits > bpsCeiling) {
121
+ errors.push('provider open fee exceeds the request maximum rate');
122
+ }
123
+ }
124
+ }
52
125
  }
53
126
  }
54
127
  if (request.lease === true && manifest.terms.lease !== true) {
@@ -57,9 +130,5 @@ function evaluateOpenRequest(manifest, request, policy = {}) {
57
130
  if (request.jit === true && manifest.terms.jit !== true) {
58
131
  errors.push('JIT is not offered by the provider');
59
132
  }
60
- if (request.maxOpenFeeBps !== undefined &&
61
- (manifest.fees.openBps ?? 0) > request.maxOpenFeeBps) {
62
- errors.push('provider open fee exceeds the request maximum');
63
- }
64
133
  return { allowed: errors.length === 0, errors, ...(asset ? { asset } : {}) };
65
134
  }
@@ -1,6 +1,7 @@
1
- import type { OmniaLspManifest, OmniaLspOpenQuote } from '@totemsdk/omnia-lsp';
1
+ import { type OmniaLspManifest, type OmniaLspOpenQuote, type OpenQuoteSigningPayload } from '@totemsdk/omnia-lsp';
2
2
  import { type OmniaLspOpenDecision, type OmniaLspOpenRequest, type OmniaLspProviderPolicy } from './policy.js';
3
3
  import { type UnsignedOmniaLspOpenQuote } from './quote.js';
4
+ import { type OmniaLspQuoteLedger } from './ledger.js';
4
5
  /**
5
6
  * Optional funding inputs for a provider-hosted open.
6
7
  *
@@ -48,29 +49,60 @@ export interface OmniaLspProviderHost {
48
49
  openChannel(input: OmniaLspHostOpenInput): Promise<OmniaLspHostOpenResult>;
49
50
  closeChannel?(channelId: string): Promise<OmniaLspHostCloseResult>;
50
51
  }
52
+ /** The authenticated caller's identity, supplied by the API layer. */
53
+ export interface OmniaLspConsumerIdentity {
54
+ address?: string;
55
+ partyId?: string;
56
+ publicKeyDigest?: string;
57
+ }
51
58
  export interface OmniaLspProviderConfig {
52
59
  manifest: OmniaLspManifest;
53
60
  host: OmniaLspProviderHost;
54
61
  policy?: OmniaLspProviderPolicy;
55
62
  /** Provider identity signer for quotes. Required for quote issuance. */
56
- signQuote: (quote: UnsignedOmniaLspOpenQuote) => Promise<string> | string;
63
+ signQuote: (quote: UnsignedOmniaLspOpenQuote, payload: OpenQuoteSigningPayload) => Promise<string> | string;
64
+ /**
65
+ * Verify a provider quote signature over `domain|termsHash` (OMN-066).
66
+ * Required to redeem a quote with `openQuote`; when absent, redemption fails
67
+ * closed rather than trusting an unverified quote.
68
+ */
69
+ verifyQuoteSignature?: (input: OpenQuoteSigningPayload & {
70
+ signature: string;
71
+ quote: OmniaLspOpenQuote;
72
+ }) => boolean | Promise<boolean>;
73
+ /**
74
+ * Durable reservation ledger (OMN-068). Defaults to an in-process ledger,
75
+ * which enforces concurrency limits but does not survive a restart.
76
+ */
77
+ quoteLedger?: OmniaLspQuoteLedger;
78
+ /**
79
+ * Require `openQuote` to be given the authenticated consumer so the quote can
80
+ * be bound to it. Default true — pass false only for a caller that has
81
+ * already authenticated the quote's consumer outside this facade.
82
+ */
83
+ requireConsumerBinding?: boolean;
57
84
  /** Default quote TTL. Default 60s. */
58
85
  quoteTtlMs?: number;
59
- /** Clock injection for deterministic tests. */
86
+ /** Clock injection for deterministic tests. The provider clock is authoritative. */
60
87
  now?: () => number;
61
88
  }
89
+ export interface OmniaLspOpenQuoteOptions {
90
+ /** Identity of the already-authenticated caller redeeming this quote. */
91
+ consumer?: OmniaLspConsumerIdentity;
92
+ }
62
93
  export interface OmniaLspProvider {
63
94
  manifest(): OmniaLspManifest;
64
95
  evaluate(request: OmniaLspOpenRequest): OmniaLspOpenDecision;
65
96
  quote(request: OmniaLspOpenRequest): Promise<OmniaLspOpenQuote>;
66
97
  open(request: OmniaLspOpenRequest, funding?: OmniaLspHostFunding | string): Promise<OmniaLspHostOpenResult>;
67
- openQuote(quote: OmniaLspOpenQuote, funding?: OmniaLspHostFunding | string): Promise<OmniaLspHostOpenResult>;
98
+ openQuote(quote: OmniaLspOpenQuote, funding?: OmniaLspHostFunding | string, options?: OmniaLspOpenQuoteOptions): Promise<OmniaLspHostOpenResult>;
68
99
  close(channelId: string): Promise<OmniaLspHostCloseResult>;
69
100
  }
70
101
  /**
71
102
  * Reference provider facade.
72
103
  *
73
104
  * It does not hold keys, open channels or broadcast. It applies policy, issues
74
- * signed quotes and delegates the channel operation to the injected host.
105
+ * signed quotes, reserves provider capacity and delegates the channel operation
106
+ * to the injected host.
75
107
  */
76
108
  export declare function createOmniaLspProvider(config: OmniaLspProviderConfig): OmniaLspProvider;