@covia/covia-sdk 1.15.0 → 1.17.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/index.d.mts CHANGED
@@ -174,7 +174,9 @@ declare abstract class Asset {
174
174
  */
175
175
  getContent(): Promise<ReadableStream<Uint8Array> | null>;
176
176
  /**
177
- * Get the URL for downloading asset content
177
+ * Get the URL for downloading asset content. Resolves any reference form
178
+ * this asset was addressed by, via the venue's canonical any-ref content
179
+ * route (covia#368).
178
180
  * @returns {string} The URL for downloading the asset content
179
181
  */
180
182
  getContentURL(): string;
@@ -523,8 +525,11 @@ declare class AssetManager {
523
525
  */
524
526
  putContent(assetId: string, content: BodyInit): Promise<ContentHashResult>;
525
527
  /**
526
- * Get asset content
527
- * @param assetId - Asset identifier
528
+ * Get asset content. Resolves any reference form the metadata endpoint
529
+ * does — a bare hash, `a/<hash>`, a workspace/operation path, or a
530
+ * DID-qualified URL — via the venue's canonical `GET /api/v1/content/{ref}`
531
+ * (covia#368), not the hash-only legacy `assets/{id}/content` route.
532
+ * @param assetId - Asset reference (any form)
528
533
  */
529
534
  getContent(assetId: string): Promise<ReadableStream<Uint8Array> | null>;
530
535
  /**
@@ -1152,7 +1157,31 @@ interface JobMetadata {
1152
1157
  updated?: string;
1153
1158
  input?: unknown;
1154
1159
  output?: unknown;
1155
- operation?: string;
1160
+ /** The operation reference that was invoked, verbatim: a venue path
1161
+ * (`v/ops/json/merge`), a caller-namespace path (`o/my-tool`), a DID URL, or
1162
+ * a bare hash when the caller pinned a definition explicitly. An inline
1163
+ * definition has no reference, so its own metadata hash stands in. Records
1164
+ * written by venues before 0.9.9 always carry the resolved hash, so readers
1165
+ * must accept both forms (covia#499).
1166
+ *
1167
+ * A path is a mutable binding: re-invoking this reference runs whatever
1168
+ * definition sits at that path now, which is not necessarily the one that
1169
+ * ran for this job. Invoke by hash when the record must pin the exact
1170
+ * definition.
1171
+ *
1172
+ * Replaces the never-populated `operation` field — the venue has always
1173
+ * emitted this as `op`. */
1174
+ op?: string;
1175
+ /** Id (hex) of the nearest *recorded* job inside whose execution this job was
1176
+ * dispatched; absent on top-level jobs (covia#500). Transient wrappers never
1177
+ * appear in a record, so a recorded grandchild dispatched through a
1178
+ * transient layer links straight to its recorded ancestor.
1179
+ *
1180
+ * Only the up-link is stored: there is no `root`, no children list and no
1181
+ * children query. Reconstruct a tree by tracing `parent` across the jobs you
1182
+ * hold. Links are venue- and user-local — a job run on another venue through
1183
+ * the grid adapter carries none. */
1184
+ parent?: string;
1156
1185
  caller?: string;
1157
1186
  error?: string;
1158
1187
  [key: string]: unknown;
package/dist/index.d.ts CHANGED
@@ -174,7 +174,9 @@ declare abstract class Asset {
174
174
  */
175
175
  getContent(): Promise<ReadableStream<Uint8Array> | null>;
176
176
  /**
177
- * Get the URL for downloading asset content
177
+ * Get the URL for downloading asset content. Resolves any reference form
178
+ * this asset was addressed by, via the venue's canonical any-ref content
179
+ * route (covia#368).
178
180
  * @returns {string} The URL for downloading the asset content
179
181
  */
180
182
  getContentURL(): string;
@@ -523,8 +525,11 @@ declare class AssetManager {
523
525
  */
524
526
  putContent(assetId: string, content: BodyInit): Promise<ContentHashResult>;
525
527
  /**
526
- * Get asset content
527
- * @param assetId - Asset identifier
528
+ * Get asset content. Resolves any reference form the metadata endpoint
529
+ * does — a bare hash, `a/<hash>`, a workspace/operation path, or a
530
+ * DID-qualified URL — via the venue's canonical `GET /api/v1/content/{ref}`
531
+ * (covia#368), not the hash-only legacy `assets/{id}/content` route.
532
+ * @param assetId - Asset reference (any form)
528
533
  */
529
534
  getContent(assetId: string): Promise<ReadableStream<Uint8Array> | null>;
530
535
  /**
@@ -1152,7 +1157,31 @@ interface JobMetadata {
1152
1157
  updated?: string;
1153
1158
  input?: unknown;
1154
1159
  output?: unknown;
1155
- operation?: string;
1160
+ /** The operation reference that was invoked, verbatim: a venue path
1161
+ * (`v/ops/json/merge`), a caller-namespace path (`o/my-tool`), a DID URL, or
1162
+ * a bare hash when the caller pinned a definition explicitly. An inline
1163
+ * definition has no reference, so its own metadata hash stands in. Records
1164
+ * written by venues before 0.9.9 always carry the resolved hash, so readers
1165
+ * must accept both forms (covia#499).
1166
+ *
1167
+ * A path is a mutable binding: re-invoking this reference runs whatever
1168
+ * definition sits at that path now, which is not necessarily the one that
1169
+ * ran for this job. Invoke by hash when the record must pin the exact
1170
+ * definition.
1171
+ *
1172
+ * Replaces the never-populated `operation` field — the venue has always
1173
+ * emitted this as `op`. */
1174
+ op?: string;
1175
+ /** Id (hex) of the nearest *recorded* job inside whose execution this job was
1176
+ * dispatched; absent on top-level jobs (covia#500). Transient wrappers never
1177
+ * appear in a record, so a recorded grandchild dispatched through a
1178
+ * transient layer links straight to its recorded ancestor.
1179
+ *
1180
+ * Only the up-link is stored: there is no `root`, no children list and no
1181
+ * children query. Reconstruct a tree by tracing `parent` across the jobs you
1182
+ * hold. Links are venue- and user-local — a job run on another venue through
1183
+ * the grid adapter carries none. */
1184
+ parent?: string;
1156
1185
  caller?: string;
1157
1186
  error?: string;
1158
1187
  [key: string]: unknown;
package/dist/index.js CHANGED
@@ -1157,7 +1157,10 @@ function createEdDSAJWT(privateKey, lifetimeSeconds = 300, audience) {
1157
1157
  sub: did,
1158
1158
  iss: did,
1159
1159
  iat: nowSecs,
1160
- exp: nowSecs + lifetimeSeconds
1160
+ // Floored defensively — lifetimeSeconds has no integer enforcement at
1161
+ // the type level, and a float exp claim can fail JWT validation on
1162
+ // servers that require a bare integer Unix timestamp (covia-sdk#46).
1163
+ exp: Math.floor(nowSecs + lifetimeSeconds)
1161
1164
  };
1162
1165
  if (audience) claims.aud = audience;
1163
1166
  const payload = JSON.stringify(claims);
@@ -2262,11 +2265,13 @@ var Asset = class {
2262
2265
  return this._assets.getContent(this.id);
2263
2266
  }
2264
2267
  /**
2265
- * Get the URL for downloading asset content
2268
+ * Get the URL for downloading asset content. Resolves any reference form
2269
+ * this asset was addressed by, via the venue's canonical any-ref content
2270
+ * route (covia#368).
2266
2271
  * @returns {string} The URL for downloading the asset content
2267
2272
  */
2268
2273
  getContentURL() {
2269
- return `${this.venue.baseUrl}/api/v1/assets/${this.id}/content`;
2274
+ return `${this.venue.baseUrl}/api/v1/content/${this.id}`;
2270
2275
  }
2271
2276
  /**
2272
2277
  * Execute the operation and await its result.
@@ -2443,14 +2448,17 @@ var AssetManager = class {
2443
2448
  }
2444
2449
  }
2445
2450
  /**
2446
- * Get asset content
2447
- * @param assetId - Asset identifier
2451
+ * Get asset content. Resolves any reference form the metadata endpoint
2452
+ * does — a bare hash, `a/<hash>`, a workspace/operation path, or a
2453
+ * DID-qualified URL — via the venue's canonical `GET /api/v1/content/{ref}`
2454
+ * (covia#368), not the hash-only legacy `assets/{id}/content` route.
2455
+ * @param assetId - Asset reference (any form)
2448
2456
  */
2449
2457
  async getContent(assetId) {
2450
2458
  try {
2451
2459
  const response = await venueStream(
2452
2460
  this.venue,
2453
- `/api/v1/assets/${assetId}/content`,
2461
+ `/api/v1/content/${assetId}`,
2454
2462
  { contentType: null }
2455
2463
  );
2456
2464
  return response.body;
@@ -3516,7 +3524,12 @@ function createUCANJWT(privateKey, audienceDID, att, lifetimeSeconds, proofs = [
3516
3524
  ucv: UCV_VERSION,
3517
3525
  att,
3518
3526
  prf: proofs,
3519
- exp: lifetimeSeconds === null ? null : nowSecs + lifetimeSeconds
3527
+ // Floored even though nowSecs already is: lifetimeSeconds is a public
3528
+ // number param with no integer enforcement, and Convex's JSON reader
3529
+ // only decodes a bare integer as CVMLong — a float exp (e.g. a caller
3530
+ // passing Date.now()/1000 + n instead of an integer offset) becomes a
3531
+ // CVMDouble the venue's UcanJwtValidator rejects outright (covia-sdk#46).
3532
+ exp: lifetimeSeconds === null ? null : Math.floor(nowSecs + lifetimeSeconds)
3520
3533
  };
3521
3534
  const signingInput = `${base64UrlEncode(encoder2.encode(header))}.${base64UrlEncode(encoder2.encode(JSON.stringify(claims)))}`;
3522
3535
  const signature = sign(encoder2.encode(signingInput), privateKey);
package/dist/index.mjs CHANGED
@@ -1155,7 +1155,10 @@ function createEdDSAJWT(privateKey, lifetimeSeconds = 300, audience) {
1155
1155
  sub: did,
1156
1156
  iss: did,
1157
1157
  iat: nowSecs,
1158
- exp: nowSecs + lifetimeSeconds
1158
+ // Floored defensively — lifetimeSeconds has no integer enforcement at
1159
+ // the type level, and a float exp claim can fail JWT validation on
1160
+ // servers that require a bare integer Unix timestamp (covia-sdk#46).
1161
+ exp: Math.floor(nowSecs + lifetimeSeconds)
1159
1162
  };
1160
1163
  if (audience) claims.aud = audience;
1161
1164
  const payload = JSON.stringify(claims);
@@ -2260,11 +2263,13 @@ var Asset = class {
2260
2263
  return this._assets.getContent(this.id);
2261
2264
  }
2262
2265
  /**
2263
- * Get the URL for downloading asset content
2266
+ * Get the URL for downloading asset content. Resolves any reference form
2267
+ * this asset was addressed by, via the venue's canonical any-ref content
2268
+ * route (covia#368).
2264
2269
  * @returns {string} The URL for downloading the asset content
2265
2270
  */
2266
2271
  getContentURL() {
2267
- return `${this.venue.baseUrl}/api/v1/assets/${this.id}/content`;
2272
+ return `${this.venue.baseUrl}/api/v1/content/${this.id}`;
2268
2273
  }
2269
2274
  /**
2270
2275
  * Execute the operation and await its result.
@@ -2441,14 +2446,17 @@ var AssetManager = class {
2441
2446
  }
2442
2447
  }
2443
2448
  /**
2444
- * Get asset content
2445
- * @param assetId - Asset identifier
2449
+ * Get asset content. Resolves any reference form the metadata endpoint
2450
+ * does — a bare hash, `a/<hash>`, a workspace/operation path, or a
2451
+ * DID-qualified URL — via the venue's canonical `GET /api/v1/content/{ref}`
2452
+ * (covia#368), not the hash-only legacy `assets/{id}/content` route.
2453
+ * @param assetId - Asset reference (any form)
2446
2454
  */
2447
2455
  async getContent(assetId) {
2448
2456
  try {
2449
2457
  const response = await venueStream(
2450
2458
  this.venue,
2451
- `/api/v1/assets/${assetId}/content`,
2459
+ `/api/v1/content/${assetId}`,
2452
2460
  { contentType: null }
2453
2461
  );
2454
2462
  return response.body;
@@ -3514,7 +3522,12 @@ function createUCANJWT(privateKey, audienceDID, att, lifetimeSeconds, proofs = [
3514
3522
  ucv: UCV_VERSION,
3515
3523
  att,
3516
3524
  prf: proofs,
3517
- exp: lifetimeSeconds === null ? null : nowSecs + lifetimeSeconds
3525
+ // Floored even though nowSecs already is: lifetimeSeconds is a public
3526
+ // number param with no integer enforcement, and Convex's JSON reader
3527
+ // only decodes a bare integer as CVMLong — a float exp (e.g. a caller
3528
+ // passing Date.now()/1000 + n instead of an integer offset) becomes a
3529
+ // CVMDouble the venue's UcanJwtValidator rejects outright (covia-sdk#46).
3530
+ exp: lifetimeSeconds === null ? null : Math.floor(nowSecs + lifetimeSeconds)
3518
3531
  };
3519
3532
  const signingInput = `${base64UrlEncode(encoder2.encode(header))}.${base64UrlEncode(encoder2.encode(JSON.stringify(claims)))}`;
3520
3533
  const signature = sign(encoder2.encode(signingInput), privateKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@covia/covia-sdk",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "description": "Typescript library for covia-ai",
5
5
  "packageManager": "pnpm@11.9.0",
6
6
  "main": "./dist/index.js",