@vibeiao/sdk 0.1.7 → 0.1.9

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.ts CHANGED
@@ -832,6 +832,27 @@ interface MemoryPingChallengeResponse {
832
832
  expires_at: string;
833
833
  message_template: string;
834
834
  }
835
+ declare const LISTING_NAME_MAX_LENGTH = 64;
836
+ declare const LISTING_TAGLINE_MAX_LENGTH = 160;
837
+ declare const LISTING_NAME_RECOMMENDED_MAX = 32;
838
+ declare const LISTING_TAGLINE_RECOMMENDED_MAX = 90;
839
+ interface ListingNamingValidationOptions {
840
+ nameMax?: number;
841
+ taglineMax?: number;
842
+ recommendedNameMax?: number;
843
+ recommendedTaglineMax?: number;
844
+ strictRecommended?: boolean;
845
+ }
846
+ interface ListingNamingValidationResult {
847
+ isValid: boolean;
848
+ normalizedName: string;
849
+ normalizedTagline: string;
850
+ errors: string[];
851
+ warnings: string[];
852
+ }
853
+ declare const normalizeListingText: (value: string) => string;
854
+ declare const validateListingNaming: (input: Pick<ListingInput, "name" | "tagline">, options?: ListingNamingValidationOptions) => ListingNamingValidationResult;
855
+ declare const sanitizeListingNaming: (input: Pick<ListingInput, "name" | "tagline">) => Pick<ListingInput, "name" | "tagline">;
835
856
  declare const buildClaimMessage: (nonce: string) => string;
836
857
  declare const buildOwnerTransferMessage: (listingId: string, newOwnerWallet: string, nonce: string) => string;
837
858
  declare const buildMemoryPingMessage: (listingId: string, timestamp: number, nonce?: string) => string;
@@ -874,6 +895,12 @@ declare class VibeClient {
874
895
  registerAgent(claimId: string, listing: ListingInput, ownerClaimId?: string): Promise<ApiResponse<ListingRecord>>;
875
896
  updateListingStatus(listingId: string, claimId: string, status: ListingStatus): Promise<ApiResponse<ListingRecord>>;
876
897
  updateListingPrice(listingId: string, claimId: string, priceUsdc: number): Promise<ApiResponse<ListingRecord>>;
898
+ deleteListing(listingId: string, claimId: string): Promise<ApiResponse<{
899
+ id: string;
900
+ deleted: boolean;
901
+ removedStorageObjects?: number;
902
+ storageCleanupErrors?: string[];
903
+ }>>;
877
904
  transferOwner(listingId: string, claimId: string, signature: string): Promise<ApiResponse<{
878
905
  listing_id: string;
879
906
  owner_wallet_id: string;
@@ -924,6 +951,7 @@ declare class VibeClient {
924
951
  }): Promise<TicketVerifyResponse>;
925
952
  private get;
926
953
  private post;
954
+ private del;
927
955
  checkLatestVersion(force?: boolean): Promise<SdkUpdateStatus>;
928
956
  private resolveUpdateStatus;
929
957
  private ensureLatestVersion;
@@ -987,4 +1015,4 @@ declare const getResourceSnapshot: (options: {
987
1015
  apiBase?: string;
988
1016
  }) => Promise<ResourceSnapshot>;
989
1017
 
990
- export { type AnalyticsPoint, type ApiResponse, type BuybackEvent, ClaimPurpose, ClaimResponse, type LeaderboardEntry, type LeaderboardQuery, ListingInput, type ListingQuery, ListingRecord, type ListingReviewCreatePayload, ListingReviewRecord, type ListingReviewResponsePayload, ListingStatus, ListingType, type ListingVersionPayload, type MarketingCampaign, type MarketingLinkOptions, type MemoryPingChallengeResponse, type MemoryPingPayload, type OpenRouterCredits, type ResourceSnapshot, ReviewGate, type ReviewGateRecord, type ReviewRequiredPayload, type SdkUpdateCheckOptions, type SdkUpdatePolicyCheckOptions, SdkUpdateRequiredError, type SdkUpdateStatus, TicketVerifyResponse, VIBEIAO_IDL, VerifiedClaimResponse, VibeClient, type VibeClientOptions, VibeRegistry, buildBadgeMarkdown, buildClaimMessage, buildJupiterSwapUrl, buildListingVersionMessage, buildMemoryPingMessage, buildOwnerTransferMessage, buildRaydiumSwapUrl, buildReviewPrompt, buildReviewRequired, buildReviewResponseMessage, buildSdkUpdateCommand, buildShareCopy, buildShareLink, buildTradeLinks, checkForSdkUpdate, checkForSdkUpdatePolicy, compareVersions, createCampaign, getResourceSnapshot };
1018
+ export { type AnalyticsPoint, type ApiResponse, type BuybackEvent, ClaimPurpose, ClaimResponse, LISTING_NAME_MAX_LENGTH, LISTING_NAME_RECOMMENDED_MAX, LISTING_TAGLINE_MAX_LENGTH, LISTING_TAGLINE_RECOMMENDED_MAX, type LeaderboardEntry, type LeaderboardQuery, ListingInput, type ListingNamingValidationOptions, type ListingNamingValidationResult, type ListingQuery, ListingRecord, type ListingReviewCreatePayload, ListingReviewRecord, type ListingReviewResponsePayload, ListingStatus, ListingType, type ListingVersionPayload, type MarketingCampaign, type MarketingLinkOptions, type MemoryPingChallengeResponse, type MemoryPingPayload, type OpenRouterCredits, type ResourceSnapshot, ReviewGate, type ReviewGateRecord, type ReviewRequiredPayload, type SdkUpdateCheckOptions, type SdkUpdatePolicyCheckOptions, SdkUpdateRequiredError, type SdkUpdateStatus, TicketVerifyResponse, VIBEIAO_IDL, VerifiedClaimResponse, VibeClient, type VibeClientOptions, VibeRegistry, buildBadgeMarkdown, buildClaimMessage, buildJupiterSwapUrl, buildListingVersionMessage, buildMemoryPingMessage, buildOwnerTransferMessage, buildRaydiumSwapUrl, buildReviewPrompt, buildReviewRequired, buildReviewResponseMessage, buildSdkUpdateCommand, buildShareCopy, buildShareLink, buildTradeLinks, checkForSdkUpdate, checkForSdkUpdatePolicy, compareVersions, createCampaign, getResourceSnapshot, normalizeListingText, sanitizeListingNaming, validateListingNaming };
package/dist/index.js CHANGED
@@ -31,6 +31,50 @@ var pickFinite = (...values) => {
31
31
  }
32
32
  return NaN;
33
33
  };
34
+ var LISTING_NAME_MAX_LENGTH = 64;
35
+ var LISTING_TAGLINE_MAX_LENGTH = 160;
36
+ var LISTING_NAME_RECOMMENDED_MAX = 32;
37
+ var LISTING_TAGLINE_RECOMMENDED_MAX = 90;
38
+ var controlCharPattern = /[\u0000-\u001f\u007f]/;
39
+ var normalizeListingText = (value) => value.replace(/\s+/g, " ").trim();
40
+ var validateListingNaming = (input, options = {}) => {
41
+ const nameMax = options.nameMax ?? LISTING_NAME_MAX_LENGTH;
42
+ const taglineMax = options.taglineMax ?? LISTING_TAGLINE_MAX_LENGTH;
43
+ const recommendedNameMax = options.recommendedNameMax ?? LISTING_NAME_RECOMMENDED_MAX;
44
+ const recommendedTaglineMax = options.recommendedTaglineMax ?? LISTING_TAGLINE_RECOMMENDED_MAX;
45
+ const strictRecommended = Boolean(options.strictRecommended);
46
+ const normalizedName = normalizeListingText(input.name || "");
47
+ const normalizedTagline = normalizeListingText(input.tagline || "");
48
+ const errors = [];
49
+ const warnings = [];
50
+ if (!normalizedName) errors.push("name_required");
51
+ if (!normalizedTagline) errors.push("tagline_required");
52
+ if (normalizedName.length > nameMax) errors.push(`name_too_long_max_${nameMax}`);
53
+ if (normalizedTagline.length > taglineMax) errors.push(`tagline_too_long_max_${taglineMax}`);
54
+ if (controlCharPattern.test(normalizedName)) errors.push("name_control_characters_not_allowed");
55
+ if (controlCharPattern.test(normalizedTagline)) errors.push("tagline_control_characters_not_allowed");
56
+ if (normalizedName.length > recommendedNameMax) {
57
+ const message = `name_recommended_max_${recommendedNameMax}`;
58
+ if (strictRecommended) errors.push(message);
59
+ else warnings.push(message);
60
+ }
61
+ if (normalizedTagline.length > recommendedTaglineMax) {
62
+ const message = `tagline_recommended_max_${recommendedTaglineMax}`;
63
+ if (strictRecommended) errors.push(message);
64
+ else warnings.push(message);
65
+ }
66
+ return {
67
+ isValid: errors.length === 0,
68
+ normalizedName,
69
+ normalizedTagline,
70
+ errors,
71
+ warnings
72
+ };
73
+ };
74
+ var sanitizeListingNaming = (input) => ({
75
+ name: normalizeListingText(input.name || ""),
76
+ tagline: normalizeListingText(input.tagline || "")
77
+ });
34
78
  var buildClaimMessage = (nonce) => `VIBEIAO-CLAIM:${nonce}`;
35
79
  var buildOwnerTransferMessage = (listingId, newOwnerWallet, nonce) => `VIBEIAO-OWNER-TRANSFER:${listingId}:${newOwnerWallet}:${nonce}`;
36
80
  var buildMemoryPingMessage = (listingId, timestamp, nonce) => nonce ? `VIBEIAO-MEMORY-PING:${listingId}:${timestamp}:${nonce}` : `VIBEIAO-MEMORY-PING:${listingId}:${timestamp}`;
@@ -70,7 +114,7 @@ var ReviewGate = class {
70
114
  var DEFAULT_API_BASE = "https://api.vibeiao.com";
71
115
  var DEFAULT_WEB_BASE = "https://vibeiao.com";
72
116
  var DEFAULT_SDK_PACKAGE = "@vibeiao/sdk";
73
- var DEFAULT_SDK_VERSION = "0.1.5" ? "0.1.5" : "0.1.4";
117
+ var DEFAULT_SDK_VERSION = "0.1.8" ? "0.1.8" : "0.1.4";
74
118
  var DEFAULT_SDK_REGISTRY = "https://registry.npmjs.org";
75
119
  var DEFAULT_SDK_POLICY_PATH = "/v1/sdk/policy";
76
120
  var DEFAULT_SDK_CHECK_INTERVAL_MS = 1e3 * 60 * 30;
@@ -264,10 +308,20 @@ var VibeClient = class {
264
308
  return this.post(`/v1/claims/${claimId}/verify`, { signature });
265
309
  }
266
310
  async createListing(claimId, listing, ownerClaimId) {
267
- return this.post("/v1/listings", { claimId, ownerClaimId, listing });
311
+ const naming = validateListingNaming({ name: listing.name, tagline: listing.tagline });
312
+ if (!naming.isValid) {
313
+ return { error: `invalid_listing_naming:${naming.errors.join(",")}` };
314
+ }
315
+ const normalizedListing = { ...listing, ...sanitizeListingNaming(listing) };
316
+ return this.post("/v1/listings", { claimId, ownerClaimId, listing: normalizedListing });
268
317
  }
269
318
  async registerAgent(claimId, listing, ownerClaimId) {
270
- return this.post("/v1/agents/register", { claimId, ownerClaimId, listing });
319
+ const naming = validateListingNaming({ name: listing.name, tagline: listing.tagline });
320
+ if (!naming.isValid) {
321
+ return { error: `invalid_listing_naming:${naming.errors.join(",")}` };
322
+ }
323
+ const normalizedListing = { ...listing, ...sanitizeListingNaming(listing) };
324
+ return this.post("/v1/agents/register", { claimId, ownerClaimId, listing: normalizedListing });
271
325
  }
272
326
  async updateListingStatus(listingId, claimId, status) {
273
327
  return this.post(`/v1/listings/${listingId}/status`, { claimId, status });
@@ -275,6 +329,12 @@ var VibeClient = class {
275
329
  async updateListingPrice(listingId, claimId, priceUsdc) {
276
330
  return this.post(`/v1/listings/${listingId}/price`, { claimId, priceUsdc });
277
331
  }
332
+ async deleteListing(listingId, claimId) {
333
+ return this.del(
334
+ `/v1/listings/${listingId}`,
335
+ { claimId }
336
+ );
337
+ }
278
338
  async transferOwner(listingId, claimId, signature) {
279
339
  return this.post(
280
340
  `/v1/listings/${listingId}/owner-transfer`,
@@ -485,6 +545,28 @@ var VibeClient = class {
485
545
  }
486
546
  return payload;
487
547
  }
548
+ async del(path, body) {
549
+ await this.ensureLatestVersion();
550
+ const response = await this.fetcher(`${this.baseUrl}${path}`, {
551
+ method: "DELETE",
552
+ headers: { "Content-Type": "application/json" },
553
+ body: body === void 0 ? void 0 : JSON.stringify(body)
554
+ });
555
+ let payload = null;
556
+ try {
557
+ payload = await readJson(response);
558
+ } catch (error) {
559
+ const details = error instanceof Error && "details" in error ? error.details : void 0;
560
+ return { error: "invalid_json_response", details };
561
+ }
562
+ if (!response.ok) {
563
+ return { error: payload?.error || "request_failed", details: payload?.details };
564
+ }
565
+ if (!payload) {
566
+ return { error: "empty_response" };
567
+ }
568
+ return payload;
569
+ }
488
570
  async checkLatestVersion(force = false) {
489
571
  if (!force && this.lastUpdateStatus && Date.now() - this.lastUpdateCheckAt < this.updateCheckIntervalMs) {
490
572
  return this.lastUpdateStatus;
@@ -658,6 +740,10 @@ var getResourceSnapshot = async (options) => {
658
740
  return snapshot;
659
741
  };
660
742
  export {
743
+ LISTING_NAME_MAX_LENGTH,
744
+ LISTING_NAME_RECOMMENDED_MAX,
745
+ LISTING_TAGLINE_MAX_LENGTH,
746
+ LISTING_TAGLINE_RECOMMENDED_MAX,
661
747
  ReviewGate,
662
748
  SdkUpdateRequiredError,
663
749
  SelfReliance,
@@ -690,5 +776,8 @@ export {
690
776
  fetchTokenBalance,
691
777
  fetchTokenBalances,
692
778
  getResourceSnapshot,
779
+ normalizeListingText,
780
+ sanitizeListingNaming,
781
+ validateListingNaming,
693
782
  withSurvival
694
783
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@vibeiao/sdk",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "0.1.7",
5
+ "version": "0.1.9",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {