@oceanprotocol/lib 10.1.0 → 11.0.0-next.2

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.
@@ -64,6 +64,7 @@ export interface ComputeEnvironmentFreeOptions {
64
64
  export interface ComputeEnvFeatures {
65
65
  computeJobs?: boolean;
66
66
  services?: boolean;
67
+ secureTls?: boolean;
67
68
  }
68
69
  export interface ComputeEnvironment {
69
70
  id: string;
@@ -2,4 +2,12 @@ export interface JwtPayload {
2
2
  address: string;
3
3
  nonce: string;
4
4
  createdAt: number;
5
+ signature?: string;
6
+ issuerPeerId?: string;
7
+ chainId?: string | null;
8
+ v?: number;
9
+ validUntil?: number;
10
+ audience?: string[];
11
+ scope?: string[];
12
+ iat?: number;
5
13
  }
@@ -59,6 +59,24 @@ export interface NodeStatusMaintenance {
59
59
  /** Detailed status only: unix seconds, drain ETA. */
60
60
  latestExpectedEndTime?: number;
61
61
  }
62
+ /**
63
+ * Node auth-token policy, read from `status.authTokenPolicy` (companion node plan §17.2). Lets a
64
+ * client discover what a node requires/accepts before minting or presenting a token.
65
+ */
66
+ export interface AuthTokenPolicy {
67
+ /** seconds — hard cap on token lifetime; clients cap `validUntil` to this. */
68
+ maxTokenLifetime: number;
69
+ /** 'disabled' = foreign tokens rejected; 'allowlist' = honored only from `trustedIssuers`. */
70
+ crossNode: 'disabled' | 'allowlist';
71
+ /** present only when crossNode === 'allowlist' — the issuer peerIds this node honors. */
72
+ trustedIssuers?: string[];
73
+ /** behaviour when a token's issuer is unreachable. */
74
+ revocationFallback: 'closed' | 'cache' | 'open';
75
+ /** seconds; present only when revocationFallback === 'cache'. */
76
+ softFailGrace?: number;
77
+ /** OJ-03: node supports the status clientChallenge / signedChallenge proof-of-possession. */
78
+ challengeSupported: true;
79
+ }
62
80
  export interface NodeStatus {
63
81
  id: string;
64
82
  publicKey: string;
@@ -67,7 +85,19 @@ export interface NodeStatus {
67
85
  version: string;
68
86
  http: boolean;
69
87
  p2p: boolean;
88
+ /**
89
+ * OJ-03: present only when the status request included a `clientChallenge`. The node's
90
+ * libp2p-identity-key signature (0x-hex) over utf8(STATUS_CHALLENGE_DOMAIN + clientChallenge),
91
+ * proving control of the key the peerId commits to. Verify with {@link verifyNodeChallenge}.
92
+ */
93
+ signedChallenge?: string;
94
+ /** Node auth-token policy (plan §17.2). Absent on nodes that predate scoped tokens. */
95
+ authTokenPolicy?: AuthTokenPolicy;
70
96
  provider: NodeStatusProvider[];
97
+ /**
98
+ * Per-chain last-indexed-block info. Populated by DETAILED status only (the node reads it from
99
+ * its metadata DB per chain); basic status — what `getNodeStatus()` requests — returns `[]`.
100
+ */
71
101
  indexer: NodeStatusIndexer[];
72
102
  escrowAddress: Record<string, string>;
73
103
  /** chainId -> subsidy-provider contract addresses the node applies. Absent on older nodes. */
@@ -82,6 +112,12 @@ export interface NodeStatus {
82
112
  * only subsidizes a job whose image matches; `{}` / absent = unrestricted. Absent on older nodes.
83
113
  */
84
114
  subsidyProviderAllowedImages?: Record<string, string[]>;
115
+ /**
116
+ * Seconds reserved to claim an escrow payment (the node's `ESCROW_CLAIM_TIMEOUT`, default 3600).
117
+ * Added to a job's `maxJobDuration` when locking escrow funds, so the caller can tell how long
118
+ * funds stay locked beyond the job's runtime. Absent on older nodes.
119
+ */
120
+ claimDurationTimeout?: number;
85
121
  /** Maintenance (drain) mode. Absent on nodes that predate the feature. */
86
122
  maintenance?: NodeStatusMaintenance;
87
123
  supportedStorage: Record<string, boolean>;
@@ -233,6 +269,7 @@ export declare const PROTOCOL_COMMANDS: {
233
269
  COMPUTE_GET_RESULT: string;
234
270
  COMPUTE_INITIALIZE: string;
235
271
  STOP_NODE: string;
272
+ STOP_JOB: string;
236
273
  REINDEX_TX: string;
237
274
  REINDEX_CHAIN: string;
238
275
  HANDLE_INDEXING_THREAD: string;
@@ -247,6 +284,7 @@ export declare const PROTOCOL_COMMANDS: {
247
284
  FIND_PEER: string;
248
285
  CREATE_AUTH_TOKEN: string;
249
286
  INVALIDATE_AUTH_TOKEN: string;
287
+ VALIDATE_AUTH_TOKEN: string;
250
288
  FETCH_CONFIG: string;
251
289
  PUSH_CONFIG: string;
252
290
  GET_LOGS: string;
@@ -293,3 +331,50 @@ export interface CompleteSignature {
293
331
  signature: string;
294
332
  }
295
333
  export type SignerOrAuthTokenOrSignature = string | Signer | CompleteSignature;
334
+ /** Sentinel to opt a token OUT of the node-scoped default audience (mint an UNRESTRICTED token). */
335
+ export declare const UNRESTRICTED_AUDIENCE = "any";
336
+ /**
337
+ * Options for {@link Provider.generateAuthToken}. All optional, but when any of audience/scope is
338
+ * set (or when the node-scoped default applies) a `validUntil` is REQUIRED and must be signed —
339
+ * ocean.js does not default it (approved breaking change, plan §10.1).
340
+ */
341
+ export interface AuthTokenOptions {
342
+ /**
343
+ * Node peerIds the token may be used at. Omitted ⇒ ocean.js defaults to `[verifiedIssuerPeerId]`
344
+ * (node-scoped, secure by default). Pass {@link UNRESTRICTED_AUDIENCE} to opt out (unrestricted,
345
+ * a reusable network-wide bearer). An explicit `[]` is rejected.
346
+ */
347
+ audience?: string[] | typeof UNRESTRICTED_AUDIENCE;
348
+ /** Protocol commands the token may perform (PROTOCOL_COMMANDS values). Omitted ⇒ any command. */
349
+ scope?: string[];
350
+ /** Absolute expiry, epoch-milliseconds integer. REQUIRED for every v2 token. */
351
+ validUntil?: number;
352
+ /**
353
+ * Escape hatch for talking to pre-OJ-03 nodes: when true, skip the issuer identity challenge and
354
+ * trust the status `id`. OFF by default; per-call only (never a global/env default). Reintroduces
355
+ * OJ-03 risk — logged loudly. (plan §8.1 / §11 L1)
356
+ */
357
+ allowUnverifiedIssuer?: boolean;
358
+ }
359
+ /** Command category for the user-facing catalog. */
360
+ export type CommandCategory = 'data' | 'compute' | 'service' | 'storage' | 'auth' | 'admin' | 'p2p' | 'status' | 'other';
361
+ /** One entry of the scope-UX command catalog (plan §9.2). */
362
+ export interface CommandInfo {
363
+ /** PROTOCOL_COMMANDS value, e.g. 'download'. */
364
+ command: string;
365
+ /** one-line human description. */
366
+ description: string;
367
+ /** may appear in an auth-token scope (false ⇒ in TOKEN_SCOPE_DISALLOWED). */
368
+ scopable: boolean;
369
+ category: CommandCategory;
370
+ /** true for the two read-only admin commands (fetchConfig, getLogs). */
371
+ adminReadonly?: boolean;
372
+ /** false for commands that reject bearer tokens entirely (mutating admin, decryptDDO). */
373
+ tokenAuth?: boolean;
374
+ }
375
+ /**
376
+ * Commands that may NOT appear in an auth-token `scope` — the client-side mirror of the node's
377
+ * `DISALLOWED_TOKEN_SCOPE_COMMANDS`. No shared package: keep in sync by hand with ocean-node
378
+ * `src/utils/constants.ts`. `fetchConfig`/`getLogs` are NOT here (they are scopable).
379
+ */
380
+ export declare const TOKEN_SCOPE_DISALLOWED: string[];
@@ -0,0 +1,59 @@
1
+ export interface AssetFilter {
2
+ chainIds?: number[];
3
+ versions?: string[];
4
+ ids?: string[];
5
+ excludeIds?: string[];
6
+ excludeNftAddresses?: string[];
7
+ owners?: string[];
8
+ anyOf?: {
9
+ ids?: string[];
10
+ owners?: string[];
11
+ datatokenAddresses?: string[];
12
+ }[];
13
+ types?: ('dataset' | 'algorithm')[];
14
+ serviceTypes?: ('access' | 'compute')[];
15
+ datatokenAddresses?: string[];
16
+ tags?: string[];
17
+ text?: string;
18
+ nftStates?: number[];
19
+ includeUnlisted?: boolean;
20
+ includePurgatory?: boolean;
21
+ priceTypes?: string[];
22
+ excludePriceTypes?: string[];
23
+ createdAfter?: string;
24
+ serviceEndpoints?: string[];
25
+ dataspace?: string;
26
+ trustedAlgorithm?: {
27
+ did: string;
28
+ serviceId: string;
29
+ };
30
+ trustedAlgorithmPublisher?: string;
31
+ indexedOnly?: boolean;
32
+ }
33
+ export type SearchQuery = {
34
+ type?: 'assets';
35
+ filter?: AssetFilter;
36
+ sort?: {
37
+ by: 'created' | 'orders' | 'price' | 'tokenSymbol' | 'relevance';
38
+ order?: 'asc' | 'desc';
39
+ };
40
+ page?: number;
41
+ size?: number;
42
+ } | {
43
+ type: 'orders';
44
+ filter: {
45
+ consumer: string;
46
+ } | {
47
+ payer: string;
48
+ };
49
+ page?: number;
50
+ size?: number;
51
+ } | {
52
+ type: 'tags';
53
+ filter?: AssetFilter;
54
+ size?: number;
55
+ };
56
+ export interface QueryResult<T = any> {
57
+ results: T[];
58
+ totalResults: number;
59
+ }
@@ -76,6 +76,7 @@ export interface ServiceJobEndpoint {
76
76
  containerPort: number;
77
77
  hostPort: number;
78
78
  url: string;
79
+ tls?: boolean;
79
80
  }
80
81
  export declare enum ServiceStatusNumber {
81
82
  Starting = 10,// DB record created by the start handler; awaits background processing
@@ -138,6 +139,7 @@ export interface ServiceJob {
138
139
  metadata?: ComputeJobMetadata;
139
140
  outputBucketId?: string;
140
141
  outputArchives?: ServiceOutputArchive[];
142
+ secureTls?: number[];
141
143
  }
142
144
  export type ServiceJobListed = Omit<ServiceJob, 'dockerCmd' | 'dockerEntrypoint' | 'dockerfile' | 'additionalDockerFiles' | 'runtimeMetrics' | 'outputArchives'>;
143
145
  export interface ServiceListFilters {
@@ -161,6 +163,7 @@ export interface ServiceContainerSpec {
161
163
  dockerCmd?: string[];
162
164
  dockerEntrypoint?: string[];
163
165
  metadata?: ComputeJobMetadata;
166
+ secureTls?: number[];
164
167
  }
165
168
  export type ServiceRestartParams = ServiceContainerSpec;
166
169
  export interface ServiceStartParams extends ServiceContainerSpec {
@@ -12,6 +12,7 @@ export * from './NFT.js';
12
12
  export * from './NFTFactory.js';
13
13
  export * from './PolicyServer.js';
14
14
  export * from './Provider.js';
15
+ export * from './Jwt.js';
15
16
  export * from './Router.js';
16
17
  export * from './ReturnTypes.js';
17
18
  export * from './Escrow.js';
@@ -20,3 +21,4 @@ export * from './OPFSubsidyProvider.js';
20
21
  export * from './OneTimeSubsidyProvider.js';
21
22
  export * from './SubsidyView.js';
22
23
  export * from './SubsidyEstimate.js';
24
+ export * from './Query.js';
@@ -139,7 +139,7 @@ export declare class Nft extends SmartContract {
139
139
  safeTransferNft<G extends boolean = false>(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId?: number, estimateGas?: G): Promise<ReceiptOrEstimate<G>>;
140
140
  safeTransferNftTx(nftAddress: string, nftOwner: string, nftReceiver: string, tokenId?: number): Promise<TransactionRequest>;
141
141
  /**
142
- * Creates or update Metadata cached by Aquarius. Also, updates the METADATA_DECRYPTOR key
142
+ * Creates or update Metadata indexed by Ocean Node. Also, updates the METADATA_DECRYPTOR key
143
143
  * @param {String} nftAddress NFT contract address
144
144
  * @param {String} address Caller address NFT Owner adress
145
145
  * @param {Number} metadataState
@@ -1,2 +1 @@
1
- export * from './Aquarius.js';
2
1
  export * from './Provider.js';
@@ -1,6 +1,6 @@
1
1
  import { Signer } from 'ethers';
2
- import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ComputeResultStream, FindComputeProvidersRequest, FindComputeProvidersResult, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, NodeStatus, NodeComputeJob, NodeMetricsSnapshot, NodeMetricsHistoryResult, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, CompleteSignature, SignerOrAuthTokenOrSignature, EscrowEventRecord, EscrowEventsFilter } from '../../@types/index.js';
3
- import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
2
+ import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ComputeResultStream, FindComputeProvidersRequest, FindComputeProvidersResult, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, NodeStatus, NodeComputeJob, NodeMetricsSnapshot, NodeMetricsHistoryResult, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, CompleteSignature, SignerOrAuthTokenOrSignature, AuthTokenOptions, AuthTokenPolicy, EscrowEventRecord, EscrowEventsFilter, SearchQuery, QueryResult } from '../../@types/index.js';
3
+ import { type Asset, type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
4
4
  import { type P2pProvider, type P2PConfig, type P2PRequestBodyStream } from './P2pProvider.js';
5
5
  export { OCEAN_P2P_PROTOCOL, type P2PConfig, type P2pProviderRecord, type Multiaddr, P2pError, type P2pErrorType, classifyP2pError, isRetryableP2pError } from './P2pProvider.js';
6
6
  export declare function getConsumerAddress(signerOrAuthToken: SignerOrAuthTokenOrSignature): Promise<string>;
@@ -113,13 +113,36 @@ export declare class BaseProvider {
113
113
  * end quietly. Optional; omitting it keeps the previous behaviour.
114
114
  */
115
115
  getComputeResult(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, offset?: number, signal?: AbortSignal): Promise<ComputeResultStream>;
116
- generateAuthToken(consumer: Signer, nodeUri: OceanNode, signal?: AbortSignal): Promise<string>;
116
+ /**
117
+ * Mint a JWT auth token.
118
+ *
119
+ * BREAKING (v10): this now mints a **node-scoped v2 token** and **requires an explicit
120
+ * `validUntil`** (epoch ms) in `options` — an old no-arg `generateAuthToken(consumer, nodeUri)`
121
+ * call throws. It also verifies the node's identity (OJ-03) before signing. Scope a token with
122
+ * `{ audience, scope, validUntil }`, or pass `{ audience: 'any', validUntil }` for an unrestricted
123
+ * token. To mint WITH cancellation, pass `options` 3rd and the `AbortSignal` 4th —
124
+ * `generateAuthToken(consumer, nodeUri, { validUntil }, signal)`. A bare `AbortSignal` is still
125
+ * accepted as the 3rd argument for backward compatibility (disambiguated by
126
+ * `normalizeAuthTokenArgs`), but on its own it supplies no `validUntil`, so that signal-only form
127
+ * can no longer mint a v2 token — it throws.
128
+ */
129
+ generateAuthToken(consumer: Signer, nodeUri: OceanNode, options?: AuthTokenOptions | AbortSignal, signal?: AbortSignal): Promise<string>;
130
+ /**
131
+ * Read the node's auth-token policy (plan §10.3) so apps/UIs can show what the node
132
+ * requires/accepts (max lifetime, cross-node federation, revocation posture) before minting or
133
+ * presenting a token. Throws when the node is unreachable (status is null); returns `undefined`
134
+ * only when the node responded but predates scoped tokens (no `authTokenPolicy`).
135
+ */
136
+ getNodeAuthTokenPolicy(nodeUri: OceanNode, signal?: AbortSignal): Promise<AuthTokenPolicy | undefined>;
117
137
  generateSignedAuthToken(address: string, signature: string, nonce: string, nodeUri: OceanNode, validUntil?: number, signal?: AbortSignal): Promise<string>;
118
138
  invalidateAuthToken(consumer: Signer, token: string, nodeUri: OceanNode, signal?: AbortSignal): Promise<{
119
139
  success: boolean;
120
140
  }>;
121
- resolveDdo(nodeUri: OceanNode, did: string, signal?: AbortSignal): Promise<any>;
141
+ resolveDdo(nodeUri: OceanNode, did: string, signal?: AbortSignal, authorization?: string): Promise<any>;
122
142
  validateDdo(nodeUri: OceanNode, ddo: DDO, signerOrAuthToken: SignerOrAuthTokenOrSignature, signal?: AbortSignal): Promise<ValidateMetadata>;
143
+ query(nodeUri: OceanNode, request: SearchQuery, signal?: AbortSignal, authorization?: string): Promise<QueryResult>;
144
+ /** Waits for the DDO (or its `txid` update); null after `maxRetries` (max 500). */
145
+ waitForIndexer(nodeUri: OceanNode, did: string, txid?: string, signal?: AbortSignal, interval?: number, maxRetries?: number, authorization?: string): Promise<Asset>;
123
146
  isValidProvider(url: OceanNode, signal?: AbortSignal): Promise<boolean>;
124
147
  PolicyServerPassthrough(nodeUri: OceanNode, request: PolicyServerPassthroughCommand, signal?: AbortSignal): Promise<any>;
125
148
  initializePSVerification(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
@@ -138,7 +161,12 @@ export declare class BaseProvider {
138
161
  setMaintenance(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, enabled: boolean, signal?: AbortSignal): Promise<{
139
162
  maintenance: boolean;
140
163
  }>;
141
- getNodeStatus(nodeUri: OceanNode, signal?: AbortSignal): Promise<NodeStatus>;
164
+ /**
165
+ * @param detailed when true, requests the node's DETAILED status (adds `indexer`,
166
+ * `c2dClusters`, `supportedSchemas`). Basic status (the default) stays cheap and returns
167
+ * `indexer: []`. Mirrors ocean-node's `status` vs `detailedStatus` split.
168
+ */
169
+ getNodeStatus(nodeUri: OceanNode, signal?: AbortSignal, detailed?: boolean): Promise<NodeStatus>;
142
170
  getNodeJobs(nodeUri: OceanNode, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
143
171
  /**
144
172
  * Queries indexed escrow events from a node. A public read — no auth is sent. Routes to HTTP
@@ -1,18 +1,14 @@
1
1
  import { Signer } from 'ethers';
2
- import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, ComputeResultStream, NodeStatus, NodeComputeJob, NodeLogEntry, NodeMetricsSnapshot, NodeMetricsHistoryResult, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, SignerOrAuthTokenOrSignature, EscrowEventRecord, EscrowEventsFilter } from '../../@types/index.js';
2
+ import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, ComputeResultStream, NodeStatus, NodeComputeJob, NodeLogEntry, NodeMetricsSnapshot, NodeMetricsHistoryResult, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, SignerOrAuthTokenOrSignature, EscrowEventRecord, EscrowEventsFilter, SearchQuery, QueryResult } from '../../@types/index.js';
3
+ import { AuthTokenOptions } from '../../@types/Provider.js';
3
4
  import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
4
5
  import { type P2PRequestBodyStream } from './P2pProvider.js';
5
6
  export declare class HttpProvider {
6
7
  protected getAuthorization(s: SignerOrAuthTokenOrSignature): string;
7
8
  private baseUrl;
9
+ private throwIfAborted;
8
10
  private getSignedCommandParams;
9
- /**
10
- * Returns the node's root info document (nodeId, chainIds, providerAddress, nodePublicKey, ...).
11
- * @param {string} nodeUri - the provider url
12
- * @return {Promise<any>}
13
- */
14
- private getNodeInfo;
15
- getNodeStatus(nodeUri: string, signal?: AbortSignal): Promise<NodeStatus>;
11
+ getNodeStatus(nodeUri: string, signal?: AbortSignal, clientChallenge?: string, detailed?: boolean): Promise<NodeStatus>;
16
12
  getNodeJobs(nodeUri: string, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
17
13
  /**
18
14
  * Returns the live per-node resource metrics snapshot via `GET /nodeMetrics`.
@@ -230,13 +226,21 @@ export declare class HttpProvider {
230
226
  * complete one.
231
227
  */
232
228
  getComputeResult(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, offset?: number, signal?: AbortSignal): Promise<ComputeResultStream>;
233
- /** Generates an auth token
229
+ /** Generates an auth token.
230
+ *
231
+ * By default (plan §10.1) this now mints a **node-scoped v2 token** proving the issuer identity
232
+ * first (OJ-03) and requiring an explicit `validUntil`. BREAKING: a call with no `options` (or
233
+ * only a `signal`) now throws unless `validUntil` is supplied in `options`. Pass
234
+ * `{ audience: 'any', validUntil }` to mint an unrestricted token (old behaviour).
235
+ *
234
236
  * @param {Signer} consumer consumer Signer wallet object
235
237
  * @param {string} nodeUri The URI of the provider we want to query
236
- * @param {AbortSignal} signal abort signal
238
+ * @param {AuthTokenOptions} [options] audience / scope / validUntil / allowUnverifiedIssuer.
239
+ * For backward compatibility an AbortSignal may be passed here instead.
240
+ * @param {AbortSignal} [signal] abort signal
237
241
  * @return {Promise<string>}
238
242
  */
239
- generateAuthToken(consumer: Signer, nodeUri: string, signal?: AbortSignal): Promise<string>;
243
+ generateAuthToken(consumer: Signer, nodeUri: string, options?: AuthTokenOptions | AbortSignal, signal?: AbortSignal): Promise<string>;
240
244
  /** Invalidates an auth token
241
245
  * @param {Signer} consumer consumer Signer wallet object
242
246
  * @param {string} token The auth token to invalidate
@@ -314,9 +318,9 @@ export declare class HttpProvider {
314
318
  private noZeroX;
315
319
  private zeroXTransformer;
316
320
  private inputMatch;
317
- resolveDdo(nodeUri: string, did: string, signal?: AbortSignal): Promise<any>;
321
+ resolveDdo(nodeUri: string, did: string, signal?: AbortSignal, authorization?: string): Promise<any>;
318
322
  validateDdo(nodeUri: string, ddo: DDO, signerOrAuthToken: SignerOrAuthTokenOrSignature, signal?: AbortSignal): Promise<ValidateMetadata>;
319
- private getData;
323
+ query(nodeUri: string, request: SearchQuery, signal?: AbortSignal, authorization?: string): Promise<QueryResult>;
320
324
  createPersistentStorageBucket(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, payload: PersistentStorageCreateBucketRequest, signal?: AbortSignal): Promise<{
321
325
  bucketId: string;
322
326
  owner: string;
@@ -1,8 +1,8 @@
1
1
  import { type Libp2p, type Libp2pOptions } from 'libp2p';
2
2
  import { type Multiaddr } from '@multiformats/multiaddr';
3
3
  import { Signer } from 'ethers';
4
- import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, ComputeResultStream, NodeStatus, NodeComputeJob, NodeMetricsSnapshot, NodeMetricsHistoryResult, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, SignerOrAuthTokenOrSignature, EscrowEventRecord, EscrowEventsFilter } from '../../@types/index.js';
5
- import { NodeLogEntry } from '../../@types/Provider.js';
4
+ import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, ComputeResultStream, NodeStatus, NodeComputeJob, NodeMetricsSnapshot, NodeMetricsHistoryResult, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, SignerOrAuthTokenOrSignature, EscrowEventRecord, EscrowEventsFilter, SearchQuery, QueryResult } from '../../@types/index.js';
5
+ import { NodeLogEntry, AuthTokenOptions } from '../../@types/Provider.js';
6
6
  import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
7
7
  import { CID } from 'multiformats/cid';
8
8
  export declare const OCEAN_P2P_PROTOCOL = "/ocean/nodes/1.0.0";
@@ -418,6 +418,13 @@ export declare class P2pProvider {
418
418
  */
419
419
  private isNotP2PCircuit;
420
420
  private peerIdFromMultiaddr;
421
+ /**
422
+ * Best-effort extraction of the target peerId string from a P2P nodeUri (a bare peerId, a
423
+ * multiaddr with /p2p/<id>, a NodeP2P.nodeId, or a PeerId object). Returns null when the target
424
+ * does not carry a peerId (e.g. a bare multiaddr) — the caller then skips the identity match.
425
+ * Used by generateAuthToken's OJ-03 check to confirm the challenged peer is the one we targeted.
426
+ */
427
+ private extractTargetPeerId;
421
428
  /**
422
429
  * Budget for a DHT walk. `dhtLookupTimeout` was documented and defaulted here from
423
430
  * the start, but the line applying it was commented out — so a lookup silently ran
@@ -465,6 +472,8 @@ export declare class P2pProvider {
465
472
  private getNodePublicKey;
466
473
  protected getAuthorization(s: SignerOrAuthTokenOrSignature): string;
467
474
  private getSignedCommandParams;
475
+ /** Extracts the target node's peerId string from a P2P nodeUri (peerId / multiaddr / NodeP2P). */
476
+ private peerIdFromNodeUri;
468
477
  /**
469
478
  * Dial the peer, send the command, and read the first response frame.
470
479
  *
@@ -520,7 +529,7 @@ export declare class P2pProvider {
520
529
  * Returns node status via P2P STATUS command.
521
530
  * @param {OceanNode} nodeUri - multiaddr of the node
522
531
  */
523
- getNodeStatus(nodeUri: OceanNode, signal?: AbortSignal): Promise<NodeStatus>;
532
+ getNodeStatus(nodeUri: OceanNode, signal?: AbortSignal, clientChallenge?: string, detailed?: boolean): Promise<NodeStatus>;
524
533
  getNodeJobs(nodeUri: OceanNode, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
525
534
  /**
526
535
  * Queries indexed escrow events via the P2P GET_ESCROW_EVENTS command. The `ranges` object
@@ -653,7 +662,7 @@ export declare class P2pProvider {
653
662
  /**
654
663
  * Generate an auth token via P2P (auto-signs with Signer).
655
664
  */
656
- generateAuthToken(consumer: Signer, nodeUri: OceanNode, signal?: AbortSignal): Promise<string>;
665
+ generateAuthToken(consumer: Signer, nodeUri: OceanNode, options?: AuthTokenOptions | AbortSignal, signal?: AbortSignal): Promise<string>;
657
666
  /**
658
667
  * Generate an auth token from a pre-signed request (no Signer needed).
659
668
  */
@@ -662,6 +671,7 @@ export declare class P2pProvider {
662
671
  * Resolve a DDO by DID via P2P GET_DDO command.
663
672
  */
664
673
  resolveDdo(nodeUri: OceanNode, did: string, signal?: AbortSignal): Promise<any>;
674
+ query(nodeUri: OceanNode, request: SearchQuery, signal?: AbortSignal): Promise<QueryResult>;
665
675
  /**
666
676
  * Validate a DDO via P2P VALIDATE_DDO command.
667
677
  */
@@ -1,5 +1,4 @@
1
1
  import { Signer } from 'ethers';
2
- import { Aquarius } from '../services/Aquarius.js';
3
2
  import { type DDO } from '@oceanprotocol/ddo-js';
4
3
  import { StorageObject } from '../@types/File.js';
5
4
  export declare const DEVELOPMENT_CHAIN_ID = 8996;
@@ -15,7 +14,6 @@ export declare function useOasisSDK(network: string | number): boolean;
15
14
  * @param encryptDDO encrypt or not?
16
15
  * @param providerUrl the provider URL
17
16
  * @param providerFeeToken the provider fee token
18
- * @param aquariusInstance aquarius, could be node instance url
19
17
  * @param allowAccessList?: string,
20
18
  * @param denyAccessList?: string
21
19
  * @returns ddo id as string
@@ -23,7 +21,7 @@ export declare function useOasisSDK(network: string | number): boolean;
23
21
  export declare function createAsset(name: string, symbol: string, owner: Signer, assetUrls: StorageObject[], // files object
24
22
  templateIDorAddress: string | number, // If string, it's template address , otherwise, it's templateId
25
23
  ddo: DDO, encryptDDO: boolean, // default is true
26
- providerUrl: string, providerFeeToken: string, aquariusInstance: Aquarius, accessListFactory?: string, // access list factory address
24
+ providerUrl: string, providerFeeToken: string, accessListFactory?: string, // access list factory address
27
25
  allowAccessList?: string, // allow list address
28
26
  denyAccessList?: string, // deny list address
29
27
  baseToken?: string, baseTokenDecimals?: number): Promise<string>;
@@ -0,0 +1,37 @@
1
+ import { AuthTokenOptions } from '../@types/Provider.js';
2
+ /**
3
+ * Backward-compat shim: `generateAuthToken(consumer, nodeUri, options?, signal?)` used to be
4
+ * `(consumer, nodeUri, signal?)`. Disambiguate a 3rd arg that is actually an AbortSignal from an
5
+ * options object.
6
+ */
7
+ export declare function normalizeAuthTokenArgs(options?: AuthTokenOptions | AbortSignal, signal?: AbortSignal): {
8
+ opts?: AuthTokenOptions;
9
+ abortSignal?: AbortSignal;
10
+ };
11
+ export interface PreparedAuthTokenRequest {
12
+ /** the exact message to sign (v2 scoped message, or the legacy concat). */
13
+ message: string;
14
+ /** whether this is a v2 (scoped) token. */
15
+ isV2: boolean;
16
+ /** the POST/P2P body WITHOUT the signature — the caller adds `signature` after signing. */
17
+ body: Record<string, any>;
18
+ }
19
+ /**
20
+ * Resolve audience / scope / validUntil into the exact signed message + request body for a
21
+ * create-auth-token request (plan §3 / §4.3 / §10.1). Mirrors the node's validation so callers get
22
+ * precise errors; the node remains authoritative.
23
+ *
24
+ * Defaults (lever A, plan §10.1): when `audience` is omitted it defaults to `[issuerPeerId]`
25
+ * (node-scoped, secure by default). Pass `UNRESTRICTED_AUDIENCE` to opt out. Whenever the token is
26
+ * v2 (essentially always, given the node-scoped default), `validUntil` is REQUIRED and is NOT
27
+ * defaulted by ocean.js — the caller must pass it (approved breaking change).
28
+ *
29
+ * @param issuerPeerId the VERIFIED issuer peerId (from the OJ-03 challenge, not the raw status id)
30
+ */
31
+ export declare function prepareAuthTokenRequest(args: {
32
+ consumerAddress: string;
33
+ nonce: string;
34
+ issuerPeerId: string;
35
+ options?: AuthTokenOptions;
36
+ maxTokenLifetime?: number;
37
+ }): PreparedAuthTokenRequest;
@@ -0,0 +1,5 @@
1
+ import { CommandInfo } from '../@types/Provider.js';
2
+ /** The command catalog keyed by command value. */
3
+ export declare const COMMANDS: Record<string, CommandInfo>;
4
+ /** The subset of commands that may appear in an auth-token scope. */
5
+ export declare function listScopableCommands(): CommandInfo[];
@@ -1,2 +1,2 @@
1
- import { JwtPayload } from '../@types/Jwt';
1
+ import { JwtPayload } from '../@types/Jwt.js';
2
2
  export declare function decodeJwt(token: string): JwtPayload;
@@ -0,0 +1,36 @@
1
+ import { AuthTokenOptions, NodeStatus } from '../@types/Provider.js';
2
+ /**
3
+ * OJ-03 — domain-separation prefix for the status identity challenge. SHARED constant: this MUST
4
+ * byte-match the node's `STATUS_CHALLENGE_DOMAIN`. Do not re-spell it.
5
+ */
6
+ export declare const STATUS_CHALLENGE_DOMAIN = "ocean-node-status-challenge-v1:";
7
+ /**
8
+ * Generate a fresh random challenge (hex string) for the OJ-03 status challenge-response.
9
+ * @param byteLength number of random bytes (default 32)
10
+ */
11
+ export declare function generateClientChallenge(byteLength?: number): string;
12
+ /**
13
+ * Verify a node's `signedChallenge` proves it controls the private key its `peerId` commits to.
14
+ *
15
+ * The node signs `utf8(STATUS_CHALLENGE_DOMAIN + clientChallenge)` with its libp2p IDENTITY key
16
+ * (secp256k1: SHA-256 + DER). We rebuild the identical bytes and verify against the public key
17
+ * extracted from the peerId (`@libp2p/peer-id`). Returns false on any error — callers fail closed.
18
+ *
19
+ * @param peerId the node peerId (status `id`)
20
+ * @param clientChallenge the challenge we sent
21
+ * @param signedChallenge the node's 0x-hex (or bare-hex) signature
22
+ */
23
+ export declare function verifyNodeChallenge(peerId: string, clientChallenge: string, signedChallenge: string): Promise<boolean>;
24
+ /**
25
+ * Resolve the issuer peerId to sign a token for, PROVING the node controls it (OJ-03, plan §8.1).
26
+ *
27
+ * Fail-closed by default: if `signedChallenge` is absent (pre-OJ-03 node) or verification fails,
28
+ * throws rather than signing over an unverified peerId. The only bypass is the explicit per-call
29
+ * `allowUnverifiedIssuer` escape hatch (plan §11 L1) — which reintroduces OJ-03 risk and is logged.
30
+ *
31
+ * @param status the status response (fetched WITH a clientChallenge)
32
+ * @param clientChallenge the challenge sent in that status request
33
+ * @param options generateAuthToken options (only `allowUnverifiedIssuer` consulted here)
34
+ * @returns the verified issuer peerId
35
+ */
36
+ export declare function resolveVerifiedIssuer(status: NodeStatus | null, clientChallenge: string, options?: AuthTokenOptions): Promise<string>;
@@ -1,4 +1,28 @@
1
1
  import { Signer } from 'ethers';
2
+ /**
3
+ * Scoped auth tokens — current token format version. SHARED wire contract with ocean-node: this
4
+ * MUST byte-match the node's `AUTH_TOKEN_VERSION`. ocean.js is the signer; ocean-node the verifier.
5
+ */
6
+ export declare const AUTH_TOKEN_VERSION = 2;
7
+ /**
8
+ * Build the v2 scoped-auth-token signed message (plan §3.2). Byte-identical to the node's
9
+ * `buildCreateAuthTokenSignatureMessage`. The golden vectors in both repos' tests pin these bytes.
10
+ *
11
+ * message =
12
+ * address + nonce + "createAuthToken" + issuerPeerId
13
+ * + "|v:" + V + "|aud:" + AUD + "|cmd:" + CMD + "|exp:" + EXP
14
+ *
15
+ * AUD/CMD are canonicalized: dedup via `new Set` BEFORE `.sort()` (default ascending string sort),
16
+ * comma-joined. Omitted ⇒ empty string. Never pass `[]` (the node rejects it).
17
+ */
18
+ export declare function buildCreateAuthTokenSignatureMessage(fields: {
19
+ address: string;
20
+ nonce: string | number;
21
+ issuerPeerId: string;
22
+ audience?: string[];
23
+ scope?: string[];
24
+ validUntil: number;
25
+ }): string;
2
26
  /**
3
27
  * Signs the hash of a message using the provided signer.
4
28
  * @param {Signer} signer - The signer to use for signing the hash.
@@ -7,6 +7,9 @@ export * from './General.js';
7
7
  export * from './Logger.js';
8
8
  export * from './minAbi.js';
9
9
  export * from './SignatureUtils.js';
10
+ export * from './AuthToken.js';
11
+ export * from './CommandCatalog.js';
12
+ export * from './NodeIdentity.js';
10
13
  export * from './TokenUtils.js';
11
14
  export * from './ProviderErrors.js';
12
15
  export * from './OrderUtils.js';
@@ -18,3 +21,4 @@ export * from './ServiceResources.js';
18
21
  export * from './ServiceCost.js';
19
22
  export * from './SubsidyImage.js';
20
23
  export * from './SubsidyEstimate.js';
24
+ export * from './Jwt.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oceanprotocol/lib",
3
3
  "source": "./src/index.ts",
4
- "version": "10.1.0",
4
+ "version": "11.0.0-next.2",
5
5
  "description": "JavaScript client library for Ocean Protocol",
6
6
  "module": "./dist/lib.module.mjs",
7
7
  "type": "module",
@@ -91,7 +91,7 @@
91
91
  "@libp2p/websockets": "^10.1.21",
92
92
  "@multiformats/multiaddr": "^13.0.3",
93
93
  "@oasisprotocol/sapphire-ethers-v6": "^6.0.1",
94
- "@oceanprotocol/ddo-js": "^1.0.0",
94
+ "@oceanprotocol/ddo-js": "^1.1.0",
95
95
  "bignumber.js": "^11.1.5",
96
96
  "cross-fetch": "^4.1.0",
97
97
  "crypto-js": "^4.2.0",
@@ -106,6 +106,7 @@
106
106
  "devDependencies": {
107
107
  "@eslint/js": "^10.0.1",
108
108
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
109
+ "@libp2p/crypto": "^5.1.23",
109
110
  "@oceanprotocol/contracts": "^3.2.0",
110
111
  "@types/chai": "^5.2.3",
111
112
  "@types/crypto-js": "^4.2.2",