@highlightxyz/cli 0.2.0 → 0.3.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.
Files changed (2) hide show
  1. package/lib/index.js +590 -98
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // package.json
3
3
  var package_default = {
4
4
  name: "@highlightxyz/cli",
5
- version: "0.2.0",
5
+ version: "0.3.0",
6
6
  description: "Official command-line interface for the Highlight API",
7
7
  keywords: [
8
8
  "cli",
@@ -209,6 +209,15 @@ var SaleAccessMode;
209
209
  SaleAccessMode2["Public"] = "PUBLIC";
210
210
  SaleAccessMode2["Gated"] = "GATED";
211
211
  })(SaleAccessMode ||= {});
212
+ var MediaPurpose;
213
+ ((MediaPurpose2) => {
214
+ MediaPurpose2["CollectionLogo"] = "CollectionLogo";
215
+ MediaPurpose2["EditionImage"] = "EditionImage";
216
+ MediaPurpose2["EditionAnimation"] = "EditionAnimation";
217
+ MediaPurpose2["SeriesAssets"] = "SeriesAssets";
218
+ MediaPurpose2["GenerativeCode"] = "GenerativeCode";
219
+ MediaPurpose2["UserAvatar"] = "UserAvatar";
220
+ })(MediaPurpose ||= {});
212
221
  var GateMatchMode;
213
222
  ((GateMatchMode2) => {
214
223
  GateMatchMode2["All"] = "ALL";
@@ -1150,8 +1159,6 @@ class Collection extends HeyApiClient {
1150
1159
  { in: "body", key: "description" },
1151
1160
  { in: "body", key: "contractId" },
1152
1161
  { in: "body", key: "contract" },
1153
- { in: "body", key: "logoMediaId" },
1154
- { in: "body", key: "image" },
1155
1162
  { in: "body", key: "type" },
1156
1163
  { in: "body", key: "royalty" },
1157
1164
  { in: "body", key: "tokenManager" }
@@ -1223,14 +1230,58 @@ class Collection extends HeyApiClient {
1223
1230
  ...params
1224
1231
  });
1225
1232
  }
1226
- finalizeBaseUri(parameters, options) {
1233
+ archiveBaseUri(parameters, options) {
1227
1234
  const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
1228
1235
  return (options?.client ?? this.client).post({
1229
- url: "/collection/{highlightId}/finalize-base-uri",
1236
+ url: "/collection/{highlightId}/archive-base-uri",
1230
1237
  ...options,
1231
1238
  ...params
1232
1239
  });
1233
1240
  }
1241
+ createMediaUploadSession(parameters, options) {
1242
+ const params = buildClientParams([parameters], [
1243
+ {
1244
+ args: [
1245
+ { in: "path", key: "highlightId" },
1246
+ { in: "body", key: "purpose" },
1247
+ { in: "body", key: "fileName" },
1248
+ { in: "body", key: "mimeType" },
1249
+ { in: "body", key: "fileSize" },
1250
+ { in: "body", key: "contentHash" }
1251
+ ]
1252
+ }
1253
+ ]);
1254
+ return (options?.client ?? this.client).post({
1255
+ url: "/collection/{highlightId}/media/upload-session",
1256
+ ...options,
1257
+ ...params,
1258
+ headers: {
1259
+ "Content-Type": "application/json",
1260
+ ...options?.headers,
1261
+ ...params.headers
1262
+ }
1263
+ });
1264
+ }
1265
+ updateMetadata(parameters, options) {
1266
+ const params = buildClientParams([parameters], [
1267
+ {
1268
+ args: [
1269
+ { in: "path", key: "highlightId" },
1270
+ { key: "collectionUpdateMetadataInput", map: "body" }
1271
+ ]
1272
+ }
1273
+ ]);
1274
+ return (options?.client ?? this.client).patch({
1275
+ url: "/collection/{highlightId}/metadata",
1276
+ ...options,
1277
+ ...params,
1278
+ headers: {
1279
+ "Content-Type": "application/json",
1280
+ ...options?.headers,
1281
+ ...params.headers
1282
+ }
1283
+ });
1284
+ }
1234
1285
  updateGenerativeDetails(parameters, options) {
1235
1286
  const params = buildClientParams([parameters], [
1236
1287
  {
@@ -1316,7 +1367,6 @@ class Collection extends HeyApiClient {
1316
1367
  { in: "body", key: "paymentRecipient" },
1317
1368
  { in: "body", key: "accessMode" },
1318
1369
  { in: "body", key: "gateId" },
1319
- { in: "body", key: "gasSponsored" },
1320
1370
  { in: "body", key: "mechanicId" },
1321
1371
  { in: "body", key: "typeConfig" },
1322
1372
  { in: "body", key: "collectorMessage" },
@@ -1553,6 +1603,41 @@ class Collection extends HeyApiClient {
1553
1603
  ...params
1554
1604
  });
1555
1605
  }
1606
+ dutchAuctionStanding(parameters, options) {
1607
+ const params = buildClientParams([parameters], [
1608
+ {
1609
+ args: [
1610
+ { in: "path", key: "highlightId" },
1611
+ { in: "path", key: "saleId" }
1612
+ ]
1613
+ }
1614
+ ]);
1615
+ return (options?.client ?? this.client).get({
1616
+ url: "/collection/{highlightId}/sales/{saleId}/dutch",
1617
+ ...options,
1618
+ ...params
1619
+ });
1620
+ }
1621
+ claimDutchRebate(parameters, options) {
1622
+ const params = buildClientParams([parameters], [
1623
+ {
1624
+ args: [
1625
+ { in: "path", key: "highlightId" },
1626
+ { in: "body", key: "saleId" }
1627
+ ]
1628
+ }
1629
+ ]);
1630
+ return (options?.client ?? this.client).post({
1631
+ url: "/collection/{highlightId}/sales/dutch/rebate",
1632
+ ...options,
1633
+ ...params,
1634
+ headers: {
1635
+ "Content-Type": "application/json",
1636
+ ...options?.headers,
1637
+ ...params.headers
1638
+ }
1639
+ });
1640
+ }
1556
1641
  deploy(parameters, options) {
1557
1642
  const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
1558
1643
  return (options?.client ?? this.client).post({
@@ -1656,6 +1741,12 @@ class Config extends HeyApiClient {
1656
1741
  ...options
1657
1742
  });
1658
1743
  }
1744
+ mediaHosts(options) {
1745
+ return (options?.client ?? this.client).get({
1746
+ url: "/config/media-hosts",
1747
+ ...options
1748
+ });
1749
+ }
1659
1750
  systemContract(parameters, options) {
1660
1751
  const params = buildClientParams([parameters], [
1661
1752
  {
@@ -1967,41 +2058,10 @@ class Mechanic extends HeyApiClient {
1967
2058
  }
1968
2059
 
1969
2060
  class Media extends HeyApiClient {
1970
- createUploadSession(parameters, options) {
1971
- const params = buildClientParams([parameters], [
1972
- {
1973
- args: [
1974
- { in: "body", key: "kind" },
1975
- { in: "body", key: "scope" },
1976
- { in: "body", key: "fileName" },
1977
- { in: "body", key: "mimeType" },
1978
- { in: "body", key: "fileSize" }
1979
- ]
1980
- }
1981
- ]);
1982
- return (options?.client ?? this.client).post({
1983
- url: "/media/upload-session",
1984
- ...options,
1985
- ...params,
1986
- headers: {
1987
- "Content-Type": "application/json",
1988
- ...options?.headers,
1989
- ...params.headers
1990
- }
1991
- });
1992
- }
1993
- upload(parameters, options) {
1994
- const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "mediaId" }] }]);
1995
- return (options?.client ?? this.client).put({
1996
- url: "/media/{mediaId}/upload",
1997
- ...options,
1998
- ...params
1999
- });
2000
- }
2001
- process(parameters, options) {
2061
+ finalizeUpload(parameters, options) {
2002
2062
  const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "mediaId" }] }]);
2003
2063
  return (options?.client ?? this.client).post({
2004
- url: "/media/{mediaId}/process",
2064
+ url: "/media/{mediaId}/finalize",
2005
2065
  ...options,
2006
2066
  ...params
2007
2067
  });
@@ -2096,6 +2156,55 @@ class Tx extends HeyApiClient {
2096
2156
  }
2097
2157
  }
2098
2158
 
2159
+ class Siwe extends HeyApiClient {
2160
+ nonce(options) {
2161
+ return (options?.client ?? this.client).post({ url: "/user/signin/siwe/nonce", ...options });
2162
+ }
2163
+ }
2164
+
2165
+ class User extends HeyApiClient {
2166
+ createMediaUploadSession(parameters, options) {
2167
+ const params = buildClientParams([parameters], [
2168
+ {
2169
+ args: [
2170
+ { in: "body", key: "purpose" },
2171
+ { in: "body", key: "fileName" },
2172
+ { in: "body", key: "mimeType" },
2173
+ { in: "body", key: "fileSize" },
2174
+ { in: "body", key: "contentHash" }
2175
+ ]
2176
+ }
2177
+ ]);
2178
+ return (options?.client ?? this.client).post({
2179
+ url: "/user/media/upload-session",
2180
+ ...options,
2181
+ ...params,
2182
+ headers: {
2183
+ "Content-Type": "application/json",
2184
+ ...options?.headers,
2185
+ ...params.headers
2186
+ }
2187
+ });
2188
+ }
2189
+ signin(parameters, options) {
2190
+ const params = buildClientParams([parameters], [{ args: [{ key: "body", map: "body" }] }]);
2191
+ return (options?.client ?? this.client).post({
2192
+ url: "/user/signin",
2193
+ ...options,
2194
+ ...params,
2195
+ headers: {
2196
+ "Content-Type": "application/json",
2197
+ ...options?.headers,
2198
+ ...params.headers
2199
+ }
2200
+ });
2201
+ }
2202
+ _siwe;
2203
+ get siwe() {
2204
+ return this._siwe ??= new Siwe({ client: this.client });
2205
+ }
2206
+ }
2207
+
2099
2208
  class Profile extends HeyApiClient {
2100
2209
  get(options) {
2101
2210
  return (options?.client ?? this.client).get({ url: "/user/profile", ...options });
@@ -2152,32 +2261,6 @@ class Profile extends HeyApiClient {
2152
2261
  }
2153
2262
  }
2154
2263
 
2155
- class Siwe extends HeyApiClient {
2156
- nonce(options) {
2157
- return (options?.client ?? this.client).post({ url: "/user/signin/siwe/nonce", ...options });
2158
- }
2159
- }
2160
-
2161
- class User extends HeyApiClient {
2162
- signin(parameters, options) {
2163
- const params = buildClientParams([parameters], [{ args: [{ key: "body", map: "body" }] }]);
2164
- return (options?.client ?? this.client).post({
2165
- url: "/user/signin",
2166
- ...options,
2167
- ...params,
2168
- headers: {
2169
- "Content-Type": "application/json",
2170
- ...options?.headers,
2171
- ...params.headers
2172
- }
2173
- });
2174
- }
2175
- _siwe;
2176
- get siwe() {
2177
- return this._siwe ??= new Siwe({ client: this.client });
2178
- }
2179
- }
2180
-
2181
2264
  class ApiKey extends HeyApiClient {
2182
2265
  list(options) {
2183
2266
  return (options?.client ?? this.client).get({ url: "/user/api-keys", ...options });
@@ -2295,14 +2378,14 @@ class HighlightClient extends HeyApiClient {
2295
2378
  get tx() {
2296
2379
  return this._tx ??= new Tx({ client: this.client });
2297
2380
  }
2298
- _profile;
2299
- get profile() {
2300
- return this._profile ??= new Profile({ client: this.client });
2301
- }
2302
2381
  _user;
2303
2382
  get user() {
2304
2383
  return this._user ??= new User({ client: this.client });
2305
2384
  }
2385
+ _profile;
2386
+ get profile() {
2387
+ return this._profile ??= new Profile({ client: this.client });
2388
+ }
2306
2389
  _apiKey;
2307
2390
  get apiKey() {
2308
2391
  return this._apiKey ??= new ApiKey({ client: this.client });
@@ -2323,7 +2406,406 @@ function createHighlightClient(config) {
2323
2406
  const client2 = createClient(resolvedConfig);
2324
2407
  return new HighlightClient({ client: client2 });
2325
2408
  }
2409
+ // ../../node_modules/@noble/hashes/esm/utils.js
2410
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2411
+ function isBytes(a) {
2412
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
2413
+ }
2414
+ function abytes(b, ...lengths) {
2415
+ if (!isBytes(b))
2416
+ throw new Error("Uint8Array expected");
2417
+ if (lengths.length > 0 && !lengths.includes(b.length))
2418
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
2419
+ }
2420
+ function aexists(instance, checkFinished = true) {
2421
+ if (instance.destroyed)
2422
+ throw new Error("Hash instance has been destroyed");
2423
+ if (checkFinished && instance.finished)
2424
+ throw new Error("Hash#digest() has already been called");
2425
+ }
2426
+ function aoutput(out, instance) {
2427
+ abytes(out);
2428
+ const min = instance.outputLen;
2429
+ if (out.length < min) {
2430
+ throw new Error("digestInto() expects output buffer of length at least " + min);
2431
+ }
2432
+ }
2433
+ function clean(...arrays) {
2434
+ for (let i = 0;i < arrays.length; i++) {
2435
+ arrays[i].fill(0);
2436
+ }
2437
+ }
2438
+ function createView(arr) {
2439
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
2440
+ }
2441
+ function rotr(word, shift) {
2442
+ return word << 32 - shift | word >>> shift;
2443
+ }
2444
+ var hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
2445
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
2446
+ function bytesToHex(bytes) {
2447
+ abytes(bytes);
2448
+ if (hasHexBuiltin)
2449
+ return bytes.toHex();
2450
+ let hex = "";
2451
+ for (let i = 0;i < bytes.length; i++) {
2452
+ hex += hexes[bytes[i]];
2453
+ }
2454
+ return hex;
2455
+ }
2456
+ function utf8ToBytes(str) {
2457
+ if (typeof str !== "string")
2458
+ throw new Error("string expected");
2459
+ return new Uint8Array(new TextEncoder().encode(str));
2460
+ }
2461
+ function toBytes(data) {
2462
+ if (typeof data === "string")
2463
+ data = utf8ToBytes(data);
2464
+ abytes(data);
2465
+ return data;
2466
+ }
2467
+ class Hash {
2468
+ }
2469
+ function createHasher(hashCons) {
2470
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
2471
+ const tmp = hashCons();
2472
+ hashC.outputLen = tmp.outputLen;
2473
+ hashC.blockLen = tmp.blockLen;
2474
+ hashC.create = () => hashCons();
2475
+ return hashC;
2476
+ }
2477
+
2478
+ // ../../node_modules/@noble/hashes/esm/_md.js
2479
+ function setBigUint64(view, byteOffset, value, isLE) {
2480
+ if (typeof view.setBigUint64 === "function")
2481
+ return view.setBigUint64(byteOffset, value, isLE);
2482
+ const _32n = BigInt(32);
2483
+ const _u32_max = BigInt(4294967295);
2484
+ const wh = Number(value >> _32n & _u32_max);
2485
+ const wl = Number(value & _u32_max);
2486
+ const h = isLE ? 4 : 0;
2487
+ const l = isLE ? 0 : 4;
2488
+ view.setUint32(byteOffset + h, wh, isLE);
2489
+ view.setUint32(byteOffset + l, wl, isLE);
2490
+ }
2491
+ function Chi(a, b, c) {
2492
+ return a & b ^ ~a & c;
2493
+ }
2494
+ function Maj(a, b, c) {
2495
+ return a & b ^ a & c ^ b & c;
2496
+ }
2497
+
2498
+ class HashMD extends Hash {
2499
+ constructor(blockLen, outputLen, padOffset, isLE) {
2500
+ super();
2501
+ this.finished = false;
2502
+ this.length = 0;
2503
+ this.pos = 0;
2504
+ this.destroyed = false;
2505
+ this.blockLen = blockLen;
2506
+ this.outputLen = outputLen;
2507
+ this.padOffset = padOffset;
2508
+ this.isLE = isLE;
2509
+ this.buffer = new Uint8Array(blockLen);
2510
+ this.view = createView(this.buffer);
2511
+ }
2512
+ update(data) {
2513
+ aexists(this);
2514
+ data = toBytes(data);
2515
+ abytes(data);
2516
+ const { view, buffer, blockLen } = this;
2517
+ const len = data.length;
2518
+ for (let pos = 0;pos < len; ) {
2519
+ const take = Math.min(blockLen - this.pos, len - pos);
2520
+ if (take === blockLen) {
2521
+ const dataView = createView(data);
2522
+ for (;blockLen <= len - pos; pos += blockLen)
2523
+ this.process(dataView, pos);
2524
+ continue;
2525
+ }
2526
+ buffer.set(data.subarray(pos, pos + take), this.pos);
2527
+ this.pos += take;
2528
+ pos += take;
2529
+ if (this.pos === blockLen) {
2530
+ this.process(view, 0);
2531
+ this.pos = 0;
2532
+ }
2533
+ }
2534
+ this.length += data.length;
2535
+ this.roundClean();
2536
+ return this;
2537
+ }
2538
+ digestInto(out) {
2539
+ aexists(this);
2540
+ aoutput(out, this);
2541
+ this.finished = true;
2542
+ const { buffer, view, blockLen, isLE } = this;
2543
+ let { pos } = this;
2544
+ buffer[pos++] = 128;
2545
+ clean(this.buffer.subarray(pos));
2546
+ if (this.padOffset > blockLen - pos) {
2547
+ this.process(view, 0);
2548
+ pos = 0;
2549
+ }
2550
+ for (let i = pos;i < blockLen; i++)
2551
+ buffer[i] = 0;
2552
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
2553
+ this.process(view, 0);
2554
+ const oview = createView(out);
2555
+ const len = this.outputLen;
2556
+ if (len % 4)
2557
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
2558
+ const outLen = len / 4;
2559
+ const state = this.get();
2560
+ if (outLen > state.length)
2561
+ throw new Error("_sha2: outputLen bigger than state");
2562
+ for (let i = 0;i < outLen; i++)
2563
+ oview.setUint32(4 * i, state[i], isLE);
2564
+ }
2565
+ digest() {
2566
+ const { buffer, outputLen } = this;
2567
+ this.digestInto(buffer);
2568
+ const res = buffer.slice(0, outputLen);
2569
+ this.destroy();
2570
+ return res;
2571
+ }
2572
+ _cloneInto(to) {
2573
+ to || (to = new this.constructor);
2574
+ to.set(...this.get());
2575
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
2576
+ to.destroyed = destroyed;
2577
+ to.finished = finished;
2578
+ to.length = length;
2579
+ to.pos = pos;
2580
+ if (length % blockLen)
2581
+ to.buffer.set(buffer);
2582
+ return to;
2583
+ }
2584
+ clone() {
2585
+ return this._cloneInto();
2586
+ }
2587
+ }
2588
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
2589
+ 1779033703,
2590
+ 3144134277,
2591
+ 1013904242,
2592
+ 2773480762,
2593
+ 1359893119,
2594
+ 2600822924,
2595
+ 528734635,
2596
+ 1541459225
2597
+ ]);
2598
+
2599
+ // ../../node_modules/@noble/hashes/esm/sha2.js
2600
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
2601
+ 1116352408,
2602
+ 1899447441,
2603
+ 3049323471,
2604
+ 3921009573,
2605
+ 961987163,
2606
+ 1508970993,
2607
+ 2453635748,
2608
+ 2870763221,
2609
+ 3624381080,
2610
+ 310598401,
2611
+ 607225278,
2612
+ 1426881987,
2613
+ 1925078388,
2614
+ 2162078206,
2615
+ 2614888103,
2616
+ 3248222580,
2617
+ 3835390401,
2618
+ 4022224774,
2619
+ 264347078,
2620
+ 604807628,
2621
+ 770255983,
2622
+ 1249150122,
2623
+ 1555081692,
2624
+ 1996064986,
2625
+ 2554220882,
2626
+ 2821834349,
2627
+ 2952996808,
2628
+ 3210313671,
2629
+ 3336571891,
2630
+ 3584528711,
2631
+ 113926993,
2632
+ 338241895,
2633
+ 666307205,
2634
+ 773529912,
2635
+ 1294757372,
2636
+ 1396182291,
2637
+ 1695183700,
2638
+ 1986661051,
2639
+ 2177026350,
2640
+ 2456956037,
2641
+ 2730485921,
2642
+ 2820302411,
2643
+ 3259730800,
2644
+ 3345764771,
2645
+ 3516065817,
2646
+ 3600352804,
2647
+ 4094571909,
2648
+ 275423344,
2649
+ 430227734,
2650
+ 506948616,
2651
+ 659060556,
2652
+ 883997877,
2653
+ 958139571,
2654
+ 1322822218,
2655
+ 1537002063,
2656
+ 1747873779,
2657
+ 1955562222,
2658
+ 2024104815,
2659
+ 2227730452,
2660
+ 2361852424,
2661
+ 2428436474,
2662
+ 2756734187,
2663
+ 3204031479,
2664
+ 3329325298
2665
+ ]);
2666
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
2667
+
2668
+ class SHA256 extends HashMD {
2669
+ constructor(outputLen = 32) {
2670
+ super(64, outputLen, 8, false);
2671
+ this.A = SHA256_IV[0] | 0;
2672
+ this.B = SHA256_IV[1] | 0;
2673
+ this.C = SHA256_IV[2] | 0;
2674
+ this.D = SHA256_IV[3] | 0;
2675
+ this.E = SHA256_IV[4] | 0;
2676
+ this.F = SHA256_IV[5] | 0;
2677
+ this.G = SHA256_IV[6] | 0;
2678
+ this.H = SHA256_IV[7] | 0;
2679
+ }
2680
+ get() {
2681
+ const { A, B, C, D, E, F, G, H } = this;
2682
+ return [A, B, C, D, E, F, G, H];
2683
+ }
2684
+ set(A, B, C, D, E, F, G, H) {
2685
+ this.A = A | 0;
2686
+ this.B = B | 0;
2687
+ this.C = C | 0;
2688
+ this.D = D | 0;
2689
+ this.E = E | 0;
2690
+ this.F = F | 0;
2691
+ this.G = G | 0;
2692
+ this.H = H | 0;
2693
+ }
2694
+ process(view, offset) {
2695
+ for (let i = 0;i < 16; i++, offset += 4)
2696
+ SHA256_W[i] = view.getUint32(offset, false);
2697
+ for (let i = 16;i < 64; i++) {
2698
+ const W15 = SHA256_W[i - 15];
2699
+ const W2 = SHA256_W[i - 2];
2700
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
2701
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
2702
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
2703
+ }
2704
+ let { A, B, C, D, E, F, G, H } = this;
2705
+ for (let i = 0;i < 64; i++) {
2706
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
2707
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
2708
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
2709
+ const T2 = sigma0 + Maj(A, B, C) | 0;
2710
+ H = G;
2711
+ G = F;
2712
+ F = E;
2713
+ E = D + T1 | 0;
2714
+ D = C;
2715
+ C = B;
2716
+ B = A;
2717
+ A = T1 + T2 | 0;
2718
+ }
2719
+ A = A + this.A | 0;
2720
+ B = B + this.B | 0;
2721
+ C = C + this.C | 0;
2722
+ D = D + this.D | 0;
2723
+ E = E + this.E | 0;
2724
+ F = F + this.F | 0;
2725
+ G = G + this.G | 0;
2726
+ H = H + this.H | 0;
2727
+ this.set(A, B, C, D, E, F, G, H);
2728
+ }
2729
+ roundClean() {
2730
+ clean(SHA256_W);
2731
+ }
2732
+ destroy() {
2733
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
2734
+ clean(this.buffer);
2735
+ }
2736
+ }
2737
+ var sha256 = /* @__PURE__ */ createHasher(() => new SHA256);
2738
+
2326
2739
  // ../sdk/src/v1/media.ts
2740
+ var isReadableStream = (source) => ("getReader" in source);
2741
+ var sha256MediaContent = async (source, options) => {
2742
+ const hasher = sha256.create();
2743
+ let bytesHashed = 0;
2744
+ const update = (chunk) => {
2745
+ if (options?.signal?.aborted) {
2746
+ throw new DOMException("Hashing aborted.", "AbortError");
2747
+ }
2748
+ hasher.update(chunk);
2749
+ bytesHashed += chunk.byteLength;
2750
+ options?.onProgress?.(bytesHashed);
2751
+ };
2752
+ if (isReadableStream(source)) {
2753
+ const reader = source.getReader();
2754
+ try {
2755
+ while (true) {
2756
+ const result = await reader.read();
2757
+ if (result.done)
2758
+ break;
2759
+ update(result.value);
2760
+ }
2761
+ } finally {
2762
+ reader.releaseLock();
2763
+ }
2764
+ } else {
2765
+ for await (const chunk of source)
2766
+ update(chunk);
2767
+ }
2768
+ return `sha256:${bytesToHex(hasher.digest())}`;
2769
+ };
2770
+ var SUPPORTED_IMAGE_CONTENT_TYPES = new Set([
2771
+ "image/avif",
2772
+ "image/gif",
2773
+ "image/heic",
2774
+ "image/heif",
2775
+ "image/jpeg",
2776
+ "image/jpg",
2777
+ "image/png",
2778
+ "image/webp"
2779
+ ]);
2780
+ var DEFAULT_MEDIA_DELIVERY_HOSTS = {
2781
+ assets: "https://assets.highlight.xyz",
2782
+ metadata: "https://metadata.highlight.xyz",
2783
+ legacyAssets: "https://highlight-creator-assets.highlight.xyz",
2784
+ arweaveGateway: "https://arweave.net",
2785
+ ipfsGateway: "https://ipfs.io"
2786
+ };
2787
+ var LEGACY_REFERENCE = /^main\//;
2788
+ var mediaUrl = (media, location, hosts = DEFAULT_MEDIA_DELIVERY_HOSTS) => {
2789
+ switch (location.provider) {
2790
+ case "R2" /* R2 */: {
2791
+ if (LEGACY_REFERENCE.test(location.reference)) {
2792
+ return `${hosts.legacyAssets}/${location.reference}`;
2793
+ }
2794
+ if (media.parentId && media.path) {
2795
+ return `${hosts.assets}/${media.parentId}/${media.path}`;
2796
+ }
2797
+ return media.kind === "Directory" /* Directory */ ? `${hosts.assets}/${media.id}/` : `${hosts.assets}/${media.id}`;
2798
+ }
2799
+ case "Arweave" /* Arweave */:
2800
+ return `${hosts.arweaveGateway}/${location.reference}`;
2801
+ case "IPFS" /* Ipfs */:
2802
+ return `${hosts.ipfsGateway}/ipfs/${location.reference.replace(/^ipfs:\/\//, "").replace(/^\//, "")}`;
2803
+ case "External" /* External */:
2804
+ return location.reference;
2805
+ default:
2806
+ return null;
2807
+ }
2808
+ };
2327
2809
  var DEFAULT_PREFERENCE = [
2328
2810
  "Archive" /* Archive */,
2329
2811
  "Origin" /* Origin */,
@@ -2331,7 +2813,7 @@ var DEFAULT_PREFERENCE = [
2331
2813
  ];
2332
2814
  var pickLocation = (media, preference) => {
2333
2815
  for (const role of preference) {
2334
- const location = media.locations.find((l) => l.role === role && l.status === "Succeeded" /* Succeeded */ && l.url !== null);
2816
+ const location = media.locations.find((l) => l.role === role && l.status === "Succeeded" /* Succeeded */);
2335
2817
  if (location)
2336
2818
  return location;
2337
2819
  }
@@ -2341,7 +2823,8 @@ var resolveMediaUrl = (media, options) => {
2341
2823
  if (!media)
2342
2824
  return null;
2343
2825
  const preference = options?.prefer ? Array.isArray(options.prefer) ? options.prefer : [options.prefer] : DEFAULT_PREFERENCE;
2344
- return pickLocation(media, preference)?.url ?? null;
2826
+ const location = pickLocation(media, preference);
2827
+ return location ? mediaUrl(media, location, options?.hosts) : null;
2345
2828
  };
2346
2829
  // src/config.ts
2347
2830
  import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
@@ -2753,7 +3236,7 @@ var requiredInputPath = (inputPath) => {
2753
3236
  var isCollectionCreateInput = (value) => {
2754
3237
  if (!isRecord3(value))
2755
3238
  return false;
2756
- if (typeof value.name !== "string" || typeof value.description !== "string" || typeof value.logoMediaId !== "string" || typeof value.image !== "string" || !Object.values(CollectionType).includes(value.type) || !isOptionalString(value.contractId) || !isOptionalString(value.tokenManager)) {
3239
+ if (typeof value.name !== "string" || typeof value.description !== "string" || typeof value.logoMediaId !== "string" || !Object.values(CollectionType).includes(value.type) || !isOptionalString(value.contractId) || !isOptionalString(value.tokenManager)) {
2757
3240
  return false;
2758
3241
  }
2759
3242
  if (value.contract !== undefined) {
@@ -2842,7 +3325,7 @@ var create = async (args, global, runtime) => {
2842
3325
  });
2843
3326
  assertNoExtraPositionals(parsed.positionals, 0);
2844
3327
  const inputPath = requiredInputPath(parsed.values.input);
2845
- const input = await readTypedJsonInput(inputPath, runtime, isCollectionCreateInput, "a collection.create object containing name, description, logoMediaId, image, type, and valid contract details");
3328
+ const input = await readTypedJsonInput(inputPath, runtime, isCollectionCreateInput, "a collection.create object containing name, description, logoMediaId, type, and valid contract details");
2846
3329
  const context = await createClientContext(runtime, global);
2847
3330
  const collection = unwrap(await context.client.collection.create(input));
2848
3331
  if (global.json) {
@@ -3060,8 +3543,10 @@ var remove = async (args, global, runtime) => {
3060
3543
  };
3061
3544
 
3062
3545
  // src/commands/media.ts
3063
- import { readFile as readFile3, stat } from "node:fs/promises";
3546
+ import { createReadStream } from "node:fs";
3547
+ import { stat } from "node:fs/promises";
3064
3548
  import path3 from "node:path";
3549
+ import { Readable } from "node:stream";
3065
3550
  var MIME_TYPES = {
3066
3551
  ".css": "text/css",
3067
3552
  ".gif": "image/gif",
@@ -3107,11 +3592,11 @@ var waitUntilReady = async (mediaId, initial, timeoutSeconds, pollIntervalSecond
3107
3592
  var upload = async (args, global, runtime) => {
3108
3593
  const parsed = parseCommandArgs(args, {
3109
3594
  options: {
3110
- kind: { type: "string" },
3595
+ collection: { type: "string" },
3111
3596
  "mime-type": { type: "string" },
3112
3597
  "no-wait": { type: "boolean" },
3113
3598
  "poll-interval": { type: "string" },
3114
- scope: { type: "string" },
3599
+ purpose: { type: "string" },
3115
3600
  timeout: { type: "string" }
3116
3601
  }
3117
3602
  });
@@ -3122,40 +3607,45 @@ var upload = async (args, global, runtime) => {
3122
3607
  if (!fileStat.isFile()) {
3123
3608
  throw new CliError(`Media input must be a file: ${inputPath}`, 2);
3124
3609
  }
3125
- const kindValue = parsed.values.kind?.toLowerCase() ?? "file";
3126
- const kind = kindValue === "file" ? "File" /* File */ : kindValue === "directory" ? "Directory" /* Directory */ : undefined;
3127
- if (!kind) {
3128
- throw new CliError('--kind must be either "file" or "directory"', 2);
3610
+ const purposes = Object.values(MediaPurpose);
3611
+ const purpose = purposes.find((value) => value === parsed.values.purpose);
3612
+ if (!purpose) {
3613
+ throw new CliError(`--purpose must be one of: ${purposes.join(", ")}`, 2);
3129
3614
  }
3130
- if (kind === "Directory" /* Directory */ && path3.extname(absolutePath).toLowerCase() !== ".zip") {
3131
- throw new CliError("Directory media must be uploaded as a .zip file", 2);
3615
+ const collectionId = parsed.values.collection;
3616
+ const needsCollection = purpose !== "UserAvatar" /* UserAvatar */;
3617
+ if (needsCollection && !collectionId) {
3618
+ throw new CliError(`--collection is required for ${purpose} uploads`, 2);
3132
3619
  }
3133
- const scopeValue = parsed.values.scope?.toLowerCase() ?? "collection";
3134
- const scope = scopeValue === "collection" ? "Collection" /* Collection */ : scopeValue === "user" ? "User" /* User */ : undefined;
3135
- if (!scope) {
3136
- throw new CliError('--scope must be either "collection" or "user"', 2);
3620
+ if (!needsCollection && collectionId) {
3621
+ throw new CliError(`--collection is not valid for ${purpose} uploads`, 2);
3137
3622
  }
3623
+ const contentHash = await sha256MediaContent(createReadStream(absolutePath));
3138
3624
  const context = await createClientContext(runtime, global);
3139
- const session = unwrap(await context.client.media.createUploadSession({
3625
+ const body = {
3140
3626
  fileName: path3.basename(absolutePath),
3141
3627
  fileSize: fileStat.size,
3142
- kind,
3143
3628
  mimeType: parsed.values["mime-type"] ?? mimeTypeFor(absolutePath),
3144
- scope
3145
- }));
3629
+ purpose,
3630
+ contentHash
3631
+ };
3632
+ const session = unwrap(collectionId ? await context.client.collection.createMediaUploadSession({
3633
+ highlightId: collectionId,
3634
+ ...body
3635
+ }) : await context.client.user.createMediaUploadSession(body));
3146
3636
  const headers = new Headers(session.upload.headers);
3147
- if (!headers.has("authorization")) {
3148
- headers.set("authorization", `Bearer ${context.apiKey}`);
3149
- }
3150
3637
  const response = await runtime.fetch(session.upload.url, {
3151
- body: await readFile3(absolutePath),
3638
+ body: Readable.toWeb(createReadStream(absolutePath)),
3639
+ duplex: "half",
3152
3640
  headers,
3153
3641
  method: session.upload.method
3154
3642
  });
3155
3643
  if (!response.ok) {
3156
3644
  throw new ApiError(await parseResponseError(response), response.status);
3157
3645
  }
3158
- let media2 = unwrap(await context.client.media.get({ mediaId: session.media.id }));
3646
+ let media2 = unwrap(await context.client.media.finalizeUpload({
3647
+ mediaId: session.uploadMediaId
3648
+ }));
3159
3649
  if (!parsed.values["no-wait"]) {
3160
3650
  media2 = await waitUntilReady(media2.id, media2, positiveNumber(parsed.values.timeout, "--timeout") ?? 300, positiveNumber(parsed.values["poll-interval"], "--poll-interval") ?? 2, runtime, async () => unwrap(await context.client.media.get({ mediaId: media2.id })));
3161
3651
  }
@@ -3199,7 +3689,7 @@ var isOptionalBoolean = (value) => value === undefined || typeof value === "bool
3199
3689
  var isSaleCreateInput = (value) => {
3200
3690
  if (!isRecord3(value))
3201
3691
  return false;
3202
- return Object.values(SaleType).includes(value.type) && typeof value.startAt === "string" && typeof value.price === "string" && typeof value.currency === "string" && typeof value.maxPerTransaction === "number" && Number.isFinite(value.maxPerTransaction) && typeof value.maxPerWallet === "number" && Number.isFinite(value.maxPerWallet) && typeof value.maxTotal === "number" && Number.isFinite(value.maxTotal) && typeof value.paymentRecipient === "string" && isOptionalNullableString(value.name) && isOptionalNullableString(value.endAt) && (value.accessMode === undefined || Object.values(SaleAccessMode).includes(value.accessMode)) && isOptionalNullableString(value.gateId) && isOptionalBoolean(value.gasSponsored) && isOptionalNullableString(value.mechanicId) && isOptionalNullableString(value.collectorMessage) && isOptionalNullableString(value.customMintFee);
3692
+ return Object.values(SaleType).includes(value.type) && typeof value.startAt === "string" && typeof value.price === "string" && typeof value.currency === "string" && typeof value.maxPerTransaction === "number" && Number.isFinite(value.maxPerTransaction) && typeof value.maxPerWallet === "number" && Number.isFinite(value.maxPerWallet) && typeof value.maxTotal === "number" && Number.isFinite(value.maxTotal) && typeof value.paymentRecipient === "string" && isOptionalNullableString(value.name) && isOptionalNullableString(value.endAt) && (value.accessMode === undefined || Object.values(SaleAccessMode).includes(value.accessMode)) && isOptionalNullableString(value.gateId) && isOptionalNullableString(value.mechanicId) && isOptionalNullableString(value.collectorMessage) && isOptionalNullableString(value.customMintFee);
3203
3693
  };
3204
3694
  var SALE_UPDATE_FIELDS = [
3205
3695
  "name",
@@ -3550,8 +4040,10 @@ var MEDIA_HELP = `Usage:
3550
4040
  hl media publish <media-id>
3551
4041
 
3552
4042
  Upload options:
3553
- --kind <file|directory> Directory inputs must be .zip files
3554
- --scope <collection|user> Media scope (default: collection)
4043
+ --purpose <purpose> Required. CollectionLogo, EditionImage,
4044
+ EditionAnimation, SeriesAssets,
4045
+ GenerativeCode, or UserAvatar
4046
+ --collection <highlight-id> Required for every purpose except UserAvatar
3555
4047
  --mime-type <type> Override inferred MIME type
3556
4048
  --no-wait Return before processing is ready
3557
4049
  --timeout <seconds> Wait timeout (default: 300)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highlightxyz/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Official command-line interface for the Highlight API",
5
5
  "keywords": [
6
6
  "cli",