@vibeiao/sdk 0.1.6 → 0.1.8

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;
@@ -987,4 +1008,4 @@ declare const getResourceSnapshot: (options: {
987
1008
  apiBase?: string;
988
1009
  }) => Promise<ResourceSnapshot>;
989
1010
 
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 };
1011
+ 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,12 +31,56 @@ 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}`;
37
81
  var buildListingVersionMessage = (listingId, version, timestamp) => `VIBEIAO-LISTING-VERSION:${listingId}:${version}:${timestamp}`;
38
82
  var buildReviewResponseMessage = (reviewId, status, timestamp) => `VIBEIAO-REVIEW-RESPONSE:${reviewId}:${status}:${timestamp}`;
39
- var buildReviewPrompt = () => "After using this tool once, provide a 1-5 star rating and a short comment (what worked, what failed, what to improve).";
83
+ var buildReviewPrompt = () => "After each paid use, submit a 1-5 star rating and a short comment (what worked, what failed, what to improve). Reviews improve discoverability, trust, and repeat demand.";
40
84
  var buildReviewRequired = (listingId, redeemSignature, appVersion, options = {}) => {
41
85
  const base = withTrailingSlash(options.baseUrl || DEFAULT_API_BASE);
42
86
  return {
@@ -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.7" ? "0.1.7" : "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 });
@@ -658,6 +712,10 @@ var getResourceSnapshot = async (options) => {
658
712
  return snapshot;
659
713
  };
660
714
  export {
715
+ LISTING_NAME_MAX_LENGTH,
716
+ LISTING_NAME_RECOMMENDED_MAX,
717
+ LISTING_TAGLINE_MAX_LENGTH,
718
+ LISTING_TAGLINE_RECOMMENDED_MAX,
661
719
  ReviewGate,
662
720
  SdkUpdateRequiredError,
663
721
  SelfReliance,
@@ -690,5 +748,8 @@ export {
690
748
  fetchTokenBalance,
691
749
  fetchTokenBalances,
692
750
  getResourceSnapshot,
751
+ normalizeListingText,
752
+ sanitizeListingNaming,
753
+ validateListingNaming,
693
754
  withSurvival
694
755
  };
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.6",
5
+ "version": "0.1.8",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {