@asi-names/sdk 0.1.0 → 0.1.1

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.cjs CHANGED
@@ -161,7 +161,18 @@ var AsiNameError = class extends Error {
161
161
  };
162
162
  function normalizeAsiName(input) {
163
163
  const trimmed = input.trim();
164
- const withTld = trimmed.toLowerCase().endsWith(".asi") ? trimmed : `${trimmed}.asi`;
164
+ if (trimmed === "") throw new AsiNameError("Name is empty");
165
+ const lower = trimmed.toLowerCase();
166
+ if (lower === "asi" || lower === ".asi") throw new AsiNameError(`"asi" is the top-level domain itself, not a name anyone holds`);
167
+ let withTld;
168
+ if (lower.endsWith(".asi")) withTld = trimmed;
169
+ else if (!trimmed.includes(".")) withTld = `${trimmed}.asi`;
170
+ else {
171
+ const tld = lower.split(".").pop();
172
+ throw new AsiNameError(
173
+ `"${trimmed}" is not a .asi name (it ends in .${tld}). It is not converted: ${lower.replace(/\.[^.]+$/, "")}.asi or ${lower}.asi would be different names, possibly held by someone else. Give a bare name ("alice") or a full .asi name ("alice.asi").`
174
+ );
175
+ }
165
176
  let name;
166
177
  try {
167
178
  name = (0, import_ens.normalize)(withTld);
package/dist/index.d.cts CHANGED
@@ -7067,7 +7067,14 @@ declare function registerName(asi: AsiClient, wallet: Wallet, params: Omit<Regis
7067
7067
  declare class AsiNameError extends Error {
7068
7068
  name: string;
7069
7069
  }
7070
- /** ENSIP-15 normalize and require a `.asi` name. Accepts "alice" or "alice.asi". */
7070
+ /**
7071
+ * ENSIP-15 normalize and require a `.asi` name. Only two shapes are accepted:
7072
+ * - a bare label: "alice" -> "alice.asi"
7073
+ * - a full .asi name: "alice.asi", "agent.lab.asi"
7074
+ * Anything else with a dot ("vitalik.eth", "jesse.base.eth", "bob.com") is REFUSED, never
7075
+ * rewritten: "vitalik.eth.asi" or "vitalik.asi" would be different names that a stranger could
7076
+ * hold, so a payment meant for vitalik.eth would reach them.
7077
+ */
7071
7078
  declare function normalizeAsiName(input: string): string;
7072
7079
  /** The second-level label of a .asi name: "agent.lab.asi" -> "lab". */
7073
7080
  declare function secondLevelLabel(name: string): string;
package/dist/index.d.ts CHANGED
@@ -7067,7 +7067,14 @@ declare function registerName(asi: AsiClient, wallet: Wallet, params: Omit<Regis
7067
7067
  declare class AsiNameError extends Error {
7068
7068
  name: string;
7069
7069
  }
7070
- /** ENSIP-15 normalize and require a `.asi` name. Accepts "alice" or "alice.asi". */
7070
+ /**
7071
+ * ENSIP-15 normalize and require a `.asi` name. Only two shapes are accepted:
7072
+ * - a bare label: "alice" -> "alice.asi"
7073
+ * - a full .asi name: "alice.asi", "agent.lab.asi"
7074
+ * Anything else with a dot ("vitalik.eth", "jesse.base.eth", "bob.com") is REFUSED, never
7075
+ * rewritten: "vitalik.eth.asi" or "vitalik.asi" would be different names that a stranger could
7076
+ * hold, so a payment meant for vitalik.eth would reach them.
7077
+ */
7071
7078
  declare function normalizeAsiName(input: string): string;
7072
7079
  /** The second-level label of a .asi name: "agent.lab.asi" -> "lab". */
7073
7080
  declare function secondLevelLabel(name: string): string;
package/dist/index.js CHANGED
@@ -128,7 +128,18 @@ var AsiNameError = class extends Error {
128
128
  };
129
129
  function normalizeAsiName(input) {
130
130
  const trimmed = input.trim();
131
- const withTld = trimmed.toLowerCase().endsWith(".asi") ? trimmed : `${trimmed}.asi`;
131
+ if (trimmed === "") throw new AsiNameError("Name is empty");
132
+ const lower = trimmed.toLowerCase();
133
+ if (lower === "asi" || lower === ".asi") throw new AsiNameError(`"asi" is the top-level domain itself, not a name anyone holds`);
134
+ let withTld;
135
+ if (lower.endsWith(".asi")) withTld = trimmed;
136
+ else if (!trimmed.includes(".")) withTld = `${trimmed}.asi`;
137
+ else {
138
+ const tld = lower.split(".").pop();
139
+ throw new AsiNameError(
140
+ `"${trimmed}" is not a .asi name (it ends in .${tld}). It is not converted: ${lower.replace(/\.[^.]+$/, "")}.asi or ${lower}.asi would be different names, possibly held by someone else. Give a bare name ("alice") or a full .asi name ("alice.asi").`
141
+ );
142
+ }
132
143
  let name;
133
144
  try {
134
145
  name = ensNormalize(withTld);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asi-names/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Resolve and register .asi names (Ethereum mainnet, resolves on every EVM chain, fully onchain).",
5
5
  "license": "MIT",
6
6
  "type": "module",