@covia/covia-sdk 1.15.0 → 1.16.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
  /**
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
  /**
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.16.0",
4
4
  "description": "Typescript library for covia-ai",
5
5
  "packageManager": "pnpm@11.9.0",
6
6
  "main": "./dist/index.js",