@topazdex/id-connect 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Topaz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # @topazdex/id-connect
2
+
3
+ Add **Topaz ID** — a self-custodial BNB Chain global wallet — to your dapp as a
4
+ one-click login. Users sign in with their existing Topaz ID account
5
+ ([id.topazdex.com](https://id.topazdex.com)); no seed phrase, no extension, and
6
+ **no Privy app of your own**.
7
+
8
+ Topaz ID is built on [Privy's global wallets](https://docs.privy.io/wallets/global-wallets/overview).
9
+ Your app is the *requester* and references Topaz ID's public app id — that's the
10
+ whole integration. You don't need a Privy account, and your domain does **not**
11
+ need to be allowlisted by Topaz ID.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ yarn add @topazdex/id-connect @privy-io/cross-app-connect wagmi viem \
17
+ @rainbow-me/rainbowkit @tanstack/react-query
18
+ ```
19
+
20
+ > `@privy-io/cross-app-connect` pins `viem@2.52.0`. Match it to avoid peer
21
+ > warnings.
22
+
23
+ ## RainbowKit
24
+
25
+ ```ts
26
+ import { topazIdWallet } from "@topazdex/id-connect/rainbow-kit";
27
+ import { connectorsForWallets } from "@rainbow-me/rainbowkit";
28
+ import { createConfig, http } from "wagmi";
29
+ import { TOPAZ_ID_CHAIN } from "@topazdex/id-connect/rainbow-kit";
30
+
31
+ const connectors = connectorsForWallets(
32
+ [{ groupName: "Sign in", wallets: [topazIdWallet()] }],
33
+ { appName: "Your App", projectId: "<walletconnect-project-id>" },
34
+ );
35
+
36
+ export const wagmiConfig = createConfig({
37
+ chains: [TOPAZ_ID_CHAIN], // BNB Chain (56)
38
+ transports: { [TOPAZ_ID_CHAIN.id]: http() },
39
+ connectors,
40
+ ssr: true,
41
+ });
42
+ ```
43
+
44
+ `"Topaz ID"` now appears in the RainbowKit picker. Selecting it opens a Topaz ID
45
+ consent window where the user signs in — no new wallet is created.
46
+
47
+ ## Plain wagmi (no RainbowKit)
48
+
49
+ ```ts
50
+ import { topazIdConnector, TOPAZ_ID_CHAIN } from "@topazdex/id-connect/rainbow-kit";
51
+ import { createConfig, http } from "wagmi";
52
+
53
+ export const wagmiConfig = createConfig({
54
+ chains: [TOPAZ_ID_CHAIN],
55
+ transports: { [TOPAZ_ID_CHAIN.id]: http() },
56
+ connectors: [topazIdConnector()],
57
+ ssr: true,
58
+ });
59
+ ```
60
+
61
+ ## Using the wallet
62
+
63
+ Once connected, Topaz ID is a standard EIP-1193 wallet. Use plain wagmi — **never**
64
+ `@privy-io/react-auth` signing hooks (those are embedded-wallet-only and won't
65
+ route through Topaz ID).
66
+
67
+ ```ts
68
+ import { useAccount, useSendTransaction } from "wagmi";
69
+ import { parseEther } from "viem";
70
+
71
+ const { address } = useAccount(); // the user's Topaz ID address
72
+
73
+ const { sendTransactionAsync } = useSendTransaction();
74
+ await sendTransactionAsync({ to, value: parseEther("0.01"), chainId: 56 });
75
+ // Topaz ID pops a consent window; the user approves every action.
76
+ ```
77
+
78
+ ## Show the user's Topaz ID profile
79
+
80
+ Topaz ID owns each wallet's name, handle, and avatar. Render real identity instead
81
+ of a bare address. Framework-agnostic helpers live at the root entry; a React Query
82
+ hook lives at `/react`.
83
+
84
+ ```ts
85
+ import { displayNameForWallet, avatarForWallet } from "@topazdex/id-connect";
86
+ import { useTopazIdProfile } from "@topazdex/id-connect/react";
87
+
88
+ const { data: profile } = useTopazIdProfile(address);
89
+ const label = displayNameForWallet(profile ?? null, address);
90
+ const avatar = avatarForWallet(profile ?? null, "/default-avatar.png");
91
+ ```
92
+
93
+ Reads are public and CORS-open. `found: false` → fall back to the address; never
94
+ block your UI on the fetch.
95
+
96
+ ## Already using Privy?
97
+
98
+ If your app is itself a Privy app, skip the connector and add Topaz ID as a
99
+ cross-app login method instead:
100
+
101
+ ```ts
102
+ // PrivyProvider config:
103
+ // loginMethods: ["email", "wallet", "privy:<topaz-id-app-id>"]
104
+ import { useCrossAppAccounts, usePrivy } from "@privy-io/react-auth";
105
+ import { TOPAZ_ID_APP_ID } from "@topazdex/id-connect";
106
+
107
+ const { user } = usePrivy();
108
+ const { loginWithCrossAppAccount } = useCrossAppAccounts();
109
+
110
+ await loginWithCrossAppAccount({ appId: TOPAZ_ID_APP_ID });
111
+
112
+ const topaz = user?.linkedAccounts.find(
113
+ (a) => a.type === "cross_app" && a.providerApp.id === TOPAZ_ID_APP_ID,
114
+ );
115
+ const address = topaz?.embeddedWallets[0]?.address;
116
+ ```
117
+
118
+ ## Exports
119
+
120
+ | Entry | Contents |
121
+ | --- | --- |
122
+ | `@topazdex/id-connect` | `TOPAZ_ID_APP_ID`, profile helpers, `TopazIdProfile` |
123
+ | `@topazdex/id-connect/rainbow-kit` | `topazIdWallet`, `topazIdConnector`, `TOPAZ_ID_CHAIN` |
124
+ | `@topazdex/id-connect/react` | `useTopazIdProfile` |
125
+
126
+ ## License
127
+
128
+ MIT
@@ -0,0 +1,9 @@
1
+ // src/constants.ts
2
+ var TOPAZ_ID_APP_ID = "cmpt1zsgh00rs0cld1hgqc0v7";
3
+ var TOPAZ_ID_NAME = "Topaz ID";
4
+ var TOPAZ_ID_ICON_URL = "https://id.topazdex.com/brand/topaz-logo.png";
5
+ var TOPAZ_ID_BASE_URL = "https://id.topazdex.com";
6
+
7
+ export { TOPAZ_ID_APP_ID, TOPAZ_ID_BASE_URL, TOPAZ_ID_ICON_URL, TOPAZ_ID_NAME };
8
+ //# sourceMappingURL=chunk-7OXTIVNI.js.map
9
+ //# sourceMappingURL=chunk-7OXTIVNI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts"],"names":[],"mappings":";AAIO,IAAM,eAAA,GAAkB;AAExB,IAAM,aAAA,GAAgB;AAEtB,IAAM,iBAAA,GACX;AAEK,IAAM,iBAAA,GAAoB","file":"chunk-7OXTIVNI.js","sourcesContent":["/**\n * Topaz ID's PUBLIC Privy app id. This is the provider app id partners reference\n * to surface Topaz ID's global wallet — it is safe to ship in client code.\n */\nexport const TOPAZ_ID_APP_ID = \"cmpt1zsgh00rs0cld1hgqc0v7\";\n\nexport const TOPAZ_ID_NAME = \"Topaz ID\";\n\nexport const TOPAZ_ID_ICON_URL =\n \"https://id.topazdex.com/brand/topaz-logo.png\";\n\nexport const TOPAZ_ID_BASE_URL = \"https://id.topazdex.com\";\n"]}
@@ -0,0 +1,26 @@
1
+ import { TOPAZ_ID_BASE_URL } from './chunk-7OXTIVNI.js';
2
+
3
+ // src/profile.ts
4
+ async function fetchTopazIdProfile(wallet, options = {}) {
5
+ const base = options.baseUrl ?? TOPAZ_ID_BASE_URL;
6
+ const res = await fetch(`${base}/api/v1/profile/${wallet}`, {
7
+ signal: options.signal
8
+ });
9
+ if (!res.ok) return null;
10
+ return await res.json();
11
+ }
12
+ function shortenAddress(wallet) {
13
+ return `${wallet.slice(0, 6)}\u2026${wallet.slice(-4)}`;
14
+ }
15
+ function displayNameForWallet(profile, wallet) {
16
+ if (profile?.handle) return `@${profile.handle}`;
17
+ if (profile?.name) return profile.name;
18
+ return shortenAddress(wallet);
19
+ }
20
+ function avatarForWallet(profile, fallback = "") {
21
+ return profile?.image ?? fallback;
22
+ }
23
+
24
+ export { avatarForWallet, displayNameForWallet, fetchTopazIdProfile, shortenAddress };
25
+ //# sourceMappingURL=chunk-NE4VWRG6.js.map
26
+ //# sourceMappingURL=chunk-NE4VWRG6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/profile.ts"],"names":[],"mappings":";;;AAkCA,eAAsB,mBAAA,CACpB,MAAA,EACA,OAAA,GAAsC,EAAC,EACP;AAChC,EAAA,MAAM,IAAA,GAAO,QAAQ,OAAA,IAAW,iBAAA;AAChC,EAAA,MAAM,MAAM,MAAM,KAAA,CAAM,GAAG,IAAI,CAAA,gBAAA,EAAmB,MAAM,CAAA,CAAA,EAAI;AAAA,IAC1D,QAAQ,OAAA,CAAQ;AAAA,GACjB,CAAA;AACD,EAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,OAAO,IAAA;AACpB,EAAA,OAAQ,MAAM,IAAI,IAAA,EAAK;AACzB;AAEO,SAAS,eAAe,MAAA,EAAwB;AACrD,EAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,MAAA,EAAI,MAAA,CAAO,KAAA,CAAM,EAAE,CAAC,CAAA,CAAA;AAClD;AAGO,SAAS,oBAAA,CACd,SACA,MAAA,EACQ;AACR,EAAA,IAAI,OAAA,EAAS,MAAA,EAAQ,OAAO,CAAA,CAAA,EAAI,QAAQ,MAAM,CAAA,CAAA;AAC9C,EAAA,IAAI,OAAA,EAAS,IAAA,EAAM,OAAO,OAAA,CAAQ,IAAA;AAClC,EAAA,OAAO,eAAe,MAAM,CAAA;AAC9B;AAGO,SAAS,eAAA,CACd,OAAA,EACA,QAAA,GAAW,EAAA,EACH;AACR,EAAA,OAAO,SAAS,KAAA,IAAS,QAAA;AAC3B","file":"chunk-NE4VWRG6.js","sourcesContent":["import { TOPAZ_ID_BASE_URL } from \"./constants\";\n\n/** Public profile shape returned by `GET /api/v1/profile/{wallet}`. */\nexport interface TopazIdProfile {\n wallet: string;\n found: boolean;\n name: string | null;\n description: string | null;\n handle: string | null;\n /** Absolute avatar URL, or null when the wallet has no avatar. */\n image: string | null;\n /** Absolute banner URL, or null. */\n banner: string | null;\n /** \"#rrggbb\" accent, or null. */\n accent: string | null;\n theme: string;\n links?: Record<string, unknown>;\n showcase?: Record<string, unknown>;\n followers?: number;\n following?: number;\n updatedAt: string | null;\n}\n\nexport interface FetchTopazIdProfileOptions {\n /** Override the Topaz ID base URL (defaults to https://id.topazdex.com). */\n baseUrl?: string;\n signal?: AbortSignal;\n}\n\n/**\n * Fetch a wallet's public Topaz ID profile. Reads are public and CORS-open — no\n * auth, no signature. Returns `null` on a network/HTTP failure; a wallet with no\n * profile resolves to an object with `found: false`.\n */\nexport async function fetchTopazIdProfile(\n wallet: string,\n options: FetchTopazIdProfileOptions = {},\n): Promise<TopazIdProfile | null> {\n const base = options.baseUrl ?? TOPAZ_ID_BASE_URL;\n const res = await fetch(`${base}/api/v1/profile/${wallet}`, {\n signal: options.signal,\n });\n if (!res.ok) return null;\n return (await res.json()) as TopazIdProfile;\n}\n\nexport function shortenAddress(wallet: string): string {\n return `${wallet.slice(0, 6)}…${wallet.slice(-4)}`;\n}\n\n/** Best display label: `@handle` → name → shortened address. */\nexport function displayNameForWallet(\n profile: TopazIdProfile | null,\n wallet: string,\n): string {\n if (profile?.handle) return `@${profile.handle}`;\n if (profile?.name) return profile.name;\n return shortenAddress(wallet);\n}\n\n/** Avatar URL from the profile, or your `fallback` when there is none. */\nexport function avatarForWallet(\n profile: TopazIdProfile | null,\n fallback = \"\",\n): string {\n return profile?.image ?? fallback;\n}\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ // src/constants.ts
4
+ var TOPAZ_ID_APP_ID = "cmpt1zsgh00rs0cld1hgqc0v7";
5
+ var TOPAZ_ID_NAME = "Topaz ID";
6
+ var TOPAZ_ID_ICON_URL = "https://id.topazdex.com/brand/topaz-logo.png";
7
+ var TOPAZ_ID_BASE_URL = "https://id.topazdex.com";
8
+
9
+ // src/profile.ts
10
+ async function fetchTopazIdProfile(wallet, options = {}) {
11
+ const base = options.baseUrl ?? TOPAZ_ID_BASE_URL;
12
+ const res = await fetch(`${base}/api/v1/profile/${wallet}`, {
13
+ signal: options.signal
14
+ });
15
+ if (!res.ok) return null;
16
+ return await res.json();
17
+ }
18
+ function shortenAddress(wallet) {
19
+ return `${wallet.slice(0, 6)}\u2026${wallet.slice(-4)}`;
20
+ }
21
+ function displayNameForWallet(profile, wallet) {
22
+ if (profile?.handle) return `@${profile.handle}`;
23
+ if (profile?.name) return profile.name;
24
+ return shortenAddress(wallet);
25
+ }
26
+ function avatarForWallet(profile, fallback = "") {
27
+ return profile?.image ?? fallback;
28
+ }
29
+
30
+ exports.TOPAZ_ID_APP_ID = TOPAZ_ID_APP_ID;
31
+ exports.TOPAZ_ID_BASE_URL = TOPAZ_ID_BASE_URL;
32
+ exports.TOPAZ_ID_ICON_URL = TOPAZ_ID_ICON_URL;
33
+ exports.TOPAZ_ID_NAME = TOPAZ_ID_NAME;
34
+ exports.avatarForWallet = avatarForWallet;
35
+ exports.displayNameForWallet = displayNameForWallet;
36
+ exports.fetchTopazIdProfile = fetchTopazIdProfile;
37
+ exports.shortenAddress = shortenAddress;
38
+ //# sourceMappingURL=index.cjs.map
39
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts","../src/profile.ts"],"names":[],"mappings":";;;AAIO,IAAM,eAAA,GAAkB;AAExB,IAAM,aAAA,GAAgB;AAEtB,IAAM,iBAAA,GACX;AAEK,IAAM,iBAAA,GAAoB;;;ACuBjC,eAAsB,mBAAA,CACpB,MAAA,EACA,OAAA,GAAsC,EAAC,EACP;AAChC,EAAA,MAAM,IAAA,GAAO,QAAQ,OAAA,IAAW,iBAAA;AAChC,EAAA,MAAM,MAAM,MAAM,KAAA,CAAM,GAAG,IAAI,CAAA,gBAAA,EAAmB,MAAM,CAAA,CAAA,EAAI;AAAA,IAC1D,QAAQ,OAAA,CAAQ;AAAA,GACjB,CAAA;AACD,EAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,OAAO,IAAA;AACpB,EAAA,OAAQ,MAAM,IAAI,IAAA,EAAK;AACzB;AAEO,SAAS,eAAe,MAAA,EAAwB;AACrD,EAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,MAAA,EAAI,MAAA,CAAO,KAAA,CAAM,EAAE,CAAC,CAAA,CAAA;AAClD;AAGO,SAAS,oBAAA,CACd,SACA,MAAA,EACQ;AACR,EAAA,IAAI,OAAA,EAAS,MAAA,EAAQ,OAAO,CAAA,CAAA,EAAI,QAAQ,MAAM,CAAA,CAAA;AAC9C,EAAA,IAAI,OAAA,EAAS,IAAA,EAAM,OAAO,OAAA,CAAQ,IAAA;AAClC,EAAA,OAAO,eAAe,MAAM,CAAA;AAC9B;AAGO,SAAS,eAAA,CACd,OAAA,EACA,QAAA,GAAW,EAAA,EACH;AACR,EAAA,OAAO,SAAS,KAAA,IAAS,QAAA;AAC3B","file":"index.cjs","sourcesContent":["/**\n * Topaz ID's PUBLIC Privy app id. This is the provider app id partners reference\n * to surface Topaz ID's global wallet — it is safe to ship in client code.\n */\nexport const TOPAZ_ID_APP_ID = \"cmpt1zsgh00rs0cld1hgqc0v7\";\n\nexport const TOPAZ_ID_NAME = \"Topaz ID\";\n\nexport const TOPAZ_ID_ICON_URL =\n \"https://id.topazdex.com/brand/topaz-logo.png\";\n\nexport const TOPAZ_ID_BASE_URL = \"https://id.topazdex.com\";\n","import { TOPAZ_ID_BASE_URL } from \"./constants\";\n\n/** Public profile shape returned by `GET /api/v1/profile/{wallet}`. */\nexport interface TopazIdProfile {\n wallet: string;\n found: boolean;\n name: string | null;\n description: string | null;\n handle: string | null;\n /** Absolute avatar URL, or null when the wallet has no avatar. */\n image: string | null;\n /** Absolute banner URL, or null. */\n banner: string | null;\n /** \"#rrggbb\" accent, or null. */\n accent: string | null;\n theme: string;\n links?: Record<string, unknown>;\n showcase?: Record<string, unknown>;\n followers?: number;\n following?: number;\n updatedAt: string | null;\n}\n\nexport interface FetchTopazIdProfileOptions {\n /** Override the Topaz ID base URL (defaults to https://id.topazdex.com). */\n baseUrl?: string;\n signal?: AbortSignal;\n}\n\n/**\n * Fetch a wallet's public Topaz ID profile. Reads are public and CORS-open — no\n * auth, no signature. Returns `null` on a network/HTTP failure; a wallet with no\n * profile resolves to an object with `found: false`.\n */\nexport async function fetchTopazIdProfile(\n wallet: string,\n options: FetchTopazIdProfileOptions = {},\n): Promise<TopazIdProfile | null> {\n const base = options.baseUrl ?? TOPAZ_ID_BASE_URL;\n const res = await fetch(`${base}/api/v1/profile/${wallet}`, {\n signal: options.signal,\n });\n if (!res.ok) return null;\n return (await res.json()) as TopazIdProfile;\n}\n\nexport function shortenAddress(wallet: string): string {\n return `${wallet.slice(0, 6)}…${wallet.slice(-4)}`;\n}\n\n/** Best display label: `@handle` → name → shortened address. */\nexport function displayNameForWallet(\n profile: TopazIdProfile | null,\n wallet: string,\n): string {\n if (profile?.handle) return `@${profile.handle}`;\n if (profile?.name) return profile.name;\n return shortenAddress(wallet);\n}\n\n/** Avatar URL from the profile, or your `fallback` when there is none. */\nexport function avatarForWallet(\n profile: TopazIdProfile | null,\n fallback = \"\",\n): string {\n return profile?.image ?? fallback;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ export { F as FetchTopazIdProfileOptions, T as TopazIdProfile, a as avatarForWallet, d as displayNameForWallet, f as fetchTopazIdProfile, s as shortenAddress } from './profile-C6bkM1cP.cjs';
2
+
3
+ /**
4
+ * Topaz ID's PUBLIC Privy app id. This is the provider app id partners reference
5
+ * to surface Topaz ID's global wallet — it is safe to ship in client code.
6
+ */
7
+ declare const TOPAZ_ID_APP_ID = "cmpt1zsgh00rs0cld1hgqc0v7";
8
+ declare const TOPAZ_ID_NAME = "Topaz ID";
9
+ declare const TOPAZ_ID_ICON_URL = "https://id.topazdex.com/brand/topaz-logo.png";
10
+ declare const TOPAZ_ID_BASE_URL = "https://id.topazdex.com";
11
+
12
+ export { TOPAZ_ID_APP_ID, TOPAZ_ID_BASE_URL, TOPAZ_ID_ICON_URL, TOPAZ_ID_NAME };
@@ -0,0 +1,12 @@
1
+ export { F as FetchTopazIdProfileOptions, T as TopazIdProfile, a as avatarForWallet, d as displayNameForWallet, f as fetchTopazIdProfile, s as shortenAddress } from './profile-C6bkM1cP.js';
2
+
3
+ /**
4
+ * Topaz ID's PUBLIC Privy app id. This is the provider app id partners reference
5
+ * to surface Topaz ID's global wallet — it is safe to ship in client code.
6
+ */
7
+ declare const TOPAZ_ID_APP_ID = "cmpt1zsgh00rs0cld1hgqc0v7";
8
+ declare const TOPAZ_ID_NAME = "Topaz ID";
9
+ declare const TOPAZ_ID_ICON_URL = "https://id.topazdex.com/brand/topaz-logo.png";
10
+ declare const TOPAZ_ID_BASE_URL = "https://id.topazdex.com";
11
+
12
+ export { TOPAZ_ID_APP_ID, TOPAZ_ID_BASE_URL, TOPAZ_ID_ICON_URL, TOPAZ_ID_NAME };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { avatarForWallet, displayNameForWallet, fetchTopazIdProfile, shortenAddress } from './chunk-NE4VWRG6.js';
2
+ export { TOPAZ_ID_APP_ID, TOPAZ_ID_BASE_URL, TOPAZ_ID_ICON_URL, TOPAZ_ID_NAME } from './chunk-7OXTIVNI.js';
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,38 @@
1
+ /** Public profile shape returned by `GET /api/v1/profile/{wallet}`. */
2
+ interface TopazIdProfile {
3
+ wallet: string;
4
+ found: boolean;
5
+ name: string | null;
6
+ description: string | null;
7
+ handle: string | null;
8
+ /** Absolute avatar URL, or null when the wallet has no avatar. */
9
+ image: string | null;
10
+ /** Absolute banner URL, or null. */
11
+ banner: string | null;
12
+ /** "#rrggbb" accent, or null. */
13
+ accent: string | null;
14
+ theme: string;
15
+ links?: Record<string, unknown>;
16
+ showcase?: Record<string, unknown>;
17
+ followers?: number;
18
+ following?: number;
19
+ updatedAt: string | null;
20
+ }
21
+ interface FetchTopazIdProfileOptions {
22
+ /** Override the Topaz ID base URL (defaults to https://id.topazdex.com). */
23
+ baseUrl?: string;
24
+ signal?: AbortSignal;
25
+ }
26
+ /**
27
+ * Fetch a wallet's public Topaz ID profile. Reads are public and CORS-open — no
28
+ * auth, no signature. Returns `null` on a network/HTTP failure; a wallet with no
29
+ * profile resolves to an object with `found: false`.
30
+ */
31
+ declare function fetchTopazIdProfile(wallet: string, options?: FetchTopazIdProfileOptions): Promise<TopazIdProfile | null>;
32
+ declare function shortenAddress(wallet: string): string;
33
+ /** Best display label: `@handle` → name → shortened address. */
34
+ declare function displayNameForWallet(profile: TopazIdProfile | null, wallet: string): string;
35
+ /** Avatar URL from the profile, or your `fallback` when there is none. */
36
+ declare function avatarForWallet(profile: TopazIdProfile | null, fallback?: string): string;
37
+
38
+ export { type FetchTopazIdProfileOptions as F, type TopazIdProfile as T, avatarForWallet as a, displayNameForWallet as d, fetchTopazIdProfile as f, shortenAddress as s };
@@ -0,0 +1,38 @@
1
+ /** Public profile shape returned by `GET /api/v1/profile/{wallet}`. */
2
+ interface TopazIdProfile {
3
+ wallet: string;
4
+ found: boolean;
5
+ name: string | null;
6
+ description: string | null;
7
+ handle: string | null;
8
+ /** Absolute avatar URL, or null when the wallet has no avatar. */
9
+ image: string | null;
10
+ /** Absolute banner URL, or null. */
11
+ banner: string | null;
12
+ /** "#rrggbb" accent, or null. */
13
+ accent: string | null;
14
+ theme: string;
15
+ links?: Record<string, unknown>;
16
+ showcase?: Record<string, unknown>;
17
+ followers?: number;
18
+ following?: number;
19
+ updatedAt: string | null;
20
+ }
21
+ interface FetchTopazIdProfileOptions {
22
+ /** Override the Topaz ID base URL (defaults to https://id.topazdex.com). */
23
+ baseUrl?: string;
24
+ signal?: AbortSignal;
25
+ }
26
+ /**
27
+ * Fetch a wallet's public Topaz ID profile. Reads are public and CORS-open — no
28
+ * auth, no signature. Returns `null` on a network/HTTP failure; a wallet with no
29
+ * profile resolves to an object with `found: false`.
30
+ */
31
+ declare function fetchTopazIdProfile(wallet: string, options?: FetchTopazIdProfileOptions): Promise<TopazIdProfile | null>;
32
+ declare function shortenAddress(wallet: string): string;
33
+ /** Best display label: `@handle` → name → shortened address. */
34
+ declare function displayNameForWallet(profile: TopazIdProfile | null, wallet: string): string;
35
+ /** Avatar URL from the profile, or your `fallback` when there is none. */
36
+ declare function avatarForWallet(profile: TopazIdProfile | null, fallback?: string): string;
37
+
38
+ export { type FetchTopazIdProfileOptions as F, type TopazIdProfile as T, avatarForWallet as a, displayNameForWallet as d, fetchTopazIdProfile as f, shortenAddress as s };
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var rainbowKit = require('@privy-io/cross-app-connect/rainbow-kit');
4
+ var chains = require('viem/chains');
5
+
6
+ // src/rainbow-kit.ts
7
+
8
+ // src/constants.ts
9
+ var TOPAZ_ID_APP_ID = "cmpt1zsgh00rs0cld1hgqc0v7";
10
+ var TOPAZ_ID_NAME = "Topaz ID";
11
+ var TOPAZ_ID_ICON_URL = "https://id.topazdex.com/brand/topaz-logo.png";
12
+
13
+ // src/rainbow-kit.ts
14
+ var TOPAZ_ID_CHAIN = chains.bsc;
15
+ function topazIdWallet(options = {}) {
16
+ return rainbowKit.toPrivyWallet({
17
+ id: options.appId ?? TOPAZ_ID_APP_ID,
18
+ name: TOPAZ_ID_NAME,
19
+ iconUrl: options.iconUrl ?? TOPAZ_ID_ICON_URL
20
+ });
21
+ }
22
+ function topazIdConnector(options = {}) {
23
+ return rainbowKit.toPrivyWalletConnector({
24
+ id: options.appId ?? TOPAZ_ID_APP_ID,
25
+ name: TOPAZ_ID_NAME,
26
+ iconUrl: options.iconUrl ?? TOPAZ_ID_ICON_URL
27
+ });
28
+ }
29
+
30
+ exports.TOPAZ_ID_CHAIN = TOPAZ_ID_CHAIN;
31
+ exports.topazIdConnector = topazIdConnector;
32
+ exports.topazIdWallet = topazIdWallet;
33
+ //# sourceMappingURL=rainbow-kit.cjs.map
34
+ //# sourceMappingURL=rainbow-kit.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts","../src/rainbow-kit.ts"],"names":["bsc","toPrivyWallet","toPrivyWalletConnector"],"mappings":";;;;;;;;AAIO,IAAM,eAAA,GAAkB,2BAAA;AAExB,IAAM,aAAA,GAAgB,UAAA;AAEtB,IAAM,iBAAA,GACX,8CAAA;;;ACDK,IAAM,cAAA,GAAiBA;AAmBvB,SAAS,aAAA,CAAc,OAAA,GAAmC,EAAC,EAAG;AACnE,EAAA,OAAOC,wBAAA,CAAc;AAAA,IACnB,EAAA,EAAI,QAAQ,KAAA,IAAS,eAAA;AAAA,IACrB,IAAA,EAAM,aAAA;AAAA,IACN,OAAA,EAAS,QAAQ,OAAA,IAAW;AAAA,GAC7B,CAAA;AACH;AAMO,SAAS,gBAAA,CAAiB,OAAA,GAAmC,EAAC,EAAG;AACtE,EAAA,OAAOC,iCAAA,CAAuB;AAAA,IAC5B,EAAA,EAAI,QAAQ,KAAA,IAAS,eAAA;AAAA,IACrB,IAAA,EAAM,aAAA;AAAA,IACN,OAAA,EAAS,QAAQ,OAAA,IAAW;AAAA,GAC7B,CAAA;AACH","file":"rainbow-kit.cjs","sourcesContent":["/**\n * Topaz ID's PUBLIC Privy app id. This is the provider app id partners reference\n * to surface Topaz ID's global wallet — it is safe to ship in client code.\n */\nexport const TOPAZ_ID_APP_ID = \"cmpt1zsgh00rs0cld1hgqc0v7\";\n\nexport const TOPAZ_ID_NAME = \"Topaz ID\";\n\nexport const TOPAZ_ID_ICON_URL =\n \"https://id.topazdex.com/brand/topaz-logo.png\";\n\nexport const TOPAZ_ID_BASE_URL = \"https://id.topazdex.com\";\n","import {\n toPrivyWallet,\n toPrivyWalletConnector,\n} from \"@privy-io/cross-app-connect/rainbow-kit\";\nimport { bsc } from \"viem/chains\";\nimport { TOPAZ_ID_APP_ID, TOPAZ_ID_ICON_URL, TOPAZ_ID_NAME } from \"./constants\";\n\n/** BNB Chain (id 56) — the chain Topaz ID wallets operate on. */\nexport const TOPAZ_ID_CHAIN = bsc;\n\nexport interface TopazIdConnectorOptions {\n /** Override Topaz ID's app id (e.g. to target a staging app). */\n appId?: string;\n /** Override the wallet icon shown in the picker. */\n iconUrl?: string;\n}\n\n/**\n * A RainbowKit wallet for Topaz ID. Drop into `connectorsForWallets`:\n *\n * ```ts\n * connectorsForWallets(\n * [{ groupName: \"Sign in\", wallets: [topazIdWallet()] }],\n * { appName: \"Your App\", projectId: WC_PROJECT_ID },\n * );\n * ```\n */\nexport function topazIdWallet(options: TopazIdConnectorOptions = {}) {\n return toPrivyWallet({\n id: options.appId ?? TOPAZ_ID_APP_ID,\n name: TOPAZ_ID_NAME,\n iconUrl: options.iconUrl ?? TOPAZ_ID_ICON_URL,\n });\n}\n\n/**\n * A plain wagmi connector for Topaz ID — no RainbowKit required. Add to\n * `createConfig({ connectors: [topazIdConnector()] })`.\n */\nexport function topazIdConnector(options: TopazIdConnectorOptions = {}) {\n return toPrivyWalletConnector({\n id: options.appId ?? TOPAZ_ID_APP_ID,\n name: TOPAZ_ID_NAME,\n iconUrl: options.iconUrl ?? TOPAZ_ID_ICON_URL,\n });\n}\n"]}
@@ -0,0 +1,80 @@
1
+ import * as wagmi from 'wagmi';
2
+ import * as _rainbow_me_rainbowkit from '@rainbow-me/rainbowkit';
3
+ import * as viem from 'viem';
4
+
5
+ /** BNB Chain (id 56) — the chain Topaz ID wallets operate on. */
6
+ declare const TOPAZ_ID_CHAIN: {
7
+ blockExplorers: {
8
+ readonly default: {
9
+ readonly name: "BscScan";
10
+ readonly url: "https://bscscan.com";
11
+ readonly apiUrl: "https://api.bscscan.com/api";
12
+ };
13
+ };
14
+ blockTime: 750;
15
+ contracts: {
16
+ readonly multicall3: {
17
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
18
+ readonly blockCreated: 15921452;
19
+ };
20
+ };
21
+ ensTlds?: readonly string[] | undefined;
22
+ id: 56;
23
+ name: "BNB Smart Chain";
24
+ nativeCurrency: {
25
+ readonly decimals: 18;
26
+ readonly name: "BNB";
27
+ readonly symbol: "BNB";
28
+ };
29
+ experimental_preconfirmationTime?: number | undefined | undefined;
30
+ rpcUrls: {
31
+ readonly default: {
32
+ readonly http: readonly ["https://56.rpc.thirdweb.com"];
33
+ };
34
+ };
35
+ sourceId?: number | undefined | undefined;
36
+ testnet?: boolean | undefined | undefined;
37
+ custom?: Record<string, unknown> | undefined;
38
+ extendSchema?: Record<string, unknown> | undefined;
39
+ fees?: viem.ChainFees<undefined> | undefined;
40
+ formatters?: undefined;
41
+ prepareTransactionRequest?: ((args: viem.PrepareTransactionRequestParameters, options: {
42
+ client: viem.Client;
43
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
44
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | [fn: ((args: viem.PrepareTransactionRequestParameters, options: {
45
+ client: viem.Client;
46
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
47
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | undefined, options: {
48
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
49
+ }] | undefined;
50
+ serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
51
+ verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
52
+ };
53
+ interface TopazIdConnectorOptions {
54
+ /** Override Topaz ID's app id (e.g. to target a staging app). */
55
+ appId?: string;
56
+ /** Override the wallet icon shown in the picker. */
57
+ iconUrl?: string;
58
+ }
59
+ /**
60
+ * A RainbowKit wallet for Topaz ID. Drop into `connectorsForWallets`:
61
+ *
62
+ * ```ts
63
+ * connectorsForWallets(
64
+ * [{ groupName: "Sign in", wallets: [topazIdWallet()] }],
65
+ * { appName: "Your App", projectId: WC_PROJECT_ID },
66
+ * );
67
+ * ```
68
+ */
69
+ declare function topazIdWallet(options?: TopazIdConnectorOptions): () => _rainbow_me_rainbowkit.Wallet;
70
+ /**
71
+ * A plain wagmi connector for Topaz ID — no RainbowKit required. Add to
72
+ * `createConfig({ connectors: [topazIdConnector()] })`.
73
+ */
74
+ declare function topazIdConnector(options?: TopazIdConnectorOptions): wagmi.CreateConnectorFn<{
75
+ on: <event extends keyof viem.EIP1193EventMap>(event: event, listener: viem.EIP1193EventMap[event]) => void;
76
+ removeListener: <event extends keyof viem.EIP1193EventMap>(event: event, listener: viem.EIP1193EventMap[event]) => void;
77
+ request: viem.EIP1193RequestFn<viem.EIP1474Methods>;
78
+ }, Record<string, unknown>, Record<string, unknown>>;
79
+
80
+ export { TOPAZ_ID_CHAIN, type TopazIdConnectorOptions, topazIdConnector, topazIdWallet };
@@ -0,0 +1,80 @@
1
+ import * as wagmi from 'wagmi';
2
+ import * as _rainbow_me_rainbowkit from '@rainbow-me/rainbowkit';
3
+ import * as viem from 'viem';
4
+
5
+ /** BNB Chain (id 56) — the chain Topaz ID wallets operate on. */
6
+ declare const TOPAZ_ID_CHAIN: {
7
+ blockExplorers: {
8
+ readonly default: {
9
+ readonly name: "BscScan";
10
+ readonly url: "https://bscscan.com";
11
+ readonly apiUrl: "https://api.bscscan.com/api";
12
+ };
13
+ };
14
+ blockTime: 750;
15
+ contracts: {
16
+ readonly multicall3: {
17
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
18
+ readonly blockCreated: 15921452;
19
+ };
20
+ };
21
+ ensTlds?: readonly string[] | undefined;
22
+ id: 56;
23
+ name: "BNB Smart Chain";
24
+ nativeCurrency: {
25
+ readonly decimals: 18;
26
+ readonly name: "BNB";
27
+ readonly symbol: "BNB";
28
+ };
29
+ experimental_preconfirmationTime?: number | undefined | undefined;
30
+ rpcUrls: {
31
+ readonly default: {
32
+ readonly http: readonly ["https://56.rpc.thirdweb.com"];
33
+ };
34
+ };
35
+ sourceId?: number | undefined | undefined;
36
+ testnet?: boolean | undefined | undefined;
37
+ custom?: Record<string, unknown> | undefined;
38
+ extendSchema?: Record<string, unknown> | undefined;
39
+ fees?: viem.ChainFees<undefined> | undefined;
40
+ formatters?: undefined;
41
+ prepareTransactionRequest?: ((args: viem.PrepareTransactionRequestParameters, options: {
42
+ client: viem.Client;
43
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
44
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | [fn: ((args: viem.PrepareTransactionRequestParameters, options: {
45
+ client: viem.Client;
46
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
47
+ }) => Promise<viem.PrepareTransactionRequestParameters>) | undefined, options: {
48
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
49
+ }] | undefined;
50
+ serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
51
+ verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
52
+ };
53
+ interface TopazIdConnectorOptions {
54
+ /** Override Topaz ID's app id (e.g. to target a staging app). */
55
+ appId?: string;
56
+ /** Override the wallet icon shown in the picker. */
57
+ iconUrl?: string;
58
+ }
59
+ /**
60
+ * A RainbowKit wallet for Topaz ID. Drop into `connectorsForWallets`:
61
+ *
62
+ * ```ts
63
+ * connectorsForWallets(
64
+ * [{ groupName: "Sign in", wallets: [topazIdWallet()] }],
65
+ * { appName: "Your App", projectId: WC_PROJECT_ID },
66
+ * );
67
+ * ```
68
+ */
69
+ declare function topazIdWallet(options?: TopazIdConnectorOptions): () => _rainbow_me_rainbowkit.Wallet;
70
+ /**
71
+ * A plain wagmi connector for Topaz ID — no RainbowKit required. Add to
72
+ * `createConfig({ connectors: [topazIdConnector()] })`.
73
+ */
74
+ declare function topazIdConnector(options?: TopazIdConnectorOptions): wagmi.CreateConnectorFn<{
75
+ on: <event extends keyof viem.EIP1193EventMap>(event: event, listener: viem.EIP1193EventMap[event]) => void;
76
+ removeListener: <event extends keyof viem.EIP1193EventMap>(event: event, listener: viem.EIP1193EventMap[event]) => void;
77
+ request: viem.EIP1193RequestFn<viem.EIP1474Methods>;
78
+ }, Record<string, unknown>, Record<string, unknown>>;
79
+
80
+ export { TOPAZ_ID_CHAIN, type TopazIdConnectorOptions, topazIdConnector, topazIdWallet };
@@ -0,0 +1,23 @@
1
+ import { TOPAZ_ID_ICON_URL, TOPAZ_ID_NAME, TOPAZ_ID_APP_ID } from './chunk-7OXTIVNI.js';
2
+ import { toPrivyWallet, toPrivyWalletConnector } from '@privy-io/cross-app-connect/rainbow-kit';
3
+ import { bsc } from 'viem/chains';
4
+
5
+ var TOPAZ_ID_CHAIN = bsc;
6
+ function topazIdWallet(options = {}) {
7
+ return toPrivyWallet({
8
+ id: options.appId ?? TOPAZ_ID_APP_ID,
9
+ name: TOPAZ_ID_NAME,
10
+ iconUrl: options.iconUrl ?? TOPAZ_ID_ICON_URL
11
+ });
12
+ }
13
+ function topazIdConnector(options = {}) {
14
+ return toPrivyWalletConnector({
15
+ id: options.appId ?? TOPAZ_ID_APP_ID,
16
+ name: TOPAZ_ID_NAME,
17
+ iconUrl: options.iconUrl ?? TOPAZ_ID_ICON_URL
18
+ });
19
+ }
20
+
21
+ export { TOPAZ_ID_CHAIN, topazIdConnector, topazIdWallet };
22
+ //# sourceMappingURL=rainbow-kit.js.map
23
+ //# sourceMappingURL=rainbow-kit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rainbow-kit.ts"],"names":[],"mappings":";;;;AAQO,IAAM,cAAA,GAAiB;AAmBvB,SAAS,aAAA,CAAc,OAAA,GAAmC,EAAC,EAAG;AACnE,EAAA,OAAO,aAAA,CAAc;AAAA,IACnB,EAAA,EAAI,QAAQ,KAAA,IAAS,eAAA;AAAA,IACrB,IAAA,EAAM,aAAA;AAAA,IACN,OAAA,EAAS,QAAQ,OAAA,IAAW;AAAA,GAC7B,CAAA;AACH;AAMO,SAAS,gBAAA,CAAiB,OAAA,GAAmC,EAAC,EAAG;AACtE,EAAA,OAAO,sBAAA,CAAuB;AAAA,IAC5B,EAAA,EAAI,QAAQ,KAAA,IAAS,eAAA;AAAA,IACrB,IAAA,EAAM,aAAA;AAAA,IACN,OAAA,EAAS,QAAQ,OAAA,IAAW;AAAA,GAC7B,CAAA;AACH","file":"rainbow-kit.js","sourcesContent":["import {\n toPrivyWallet,\n toPrivyWalletConnector,\n} from \"@privy-io/cross-app-connect/rainbow-kit\";\nimport { bsc } from \"viem/chains\";\nimport { TOPAZ_ID_APP_ID, TOPAZ_ID_ICON_URL, TOPAZ_ID_NAME } from \"./constants\";\n\n/** BNB Chain (id 56) — the chain Topaz ID wallets operate on. */\nexport const TOPAZ_ID_CHAIN = bsc;\n\nexport interface TopazIdConnectorOptions {\n /** Override Topaz ID's app id (e.g. to target a staging app). */\n appId?: string;\n /** Override the wallet icon shown in the picker. */\n iconUrl?: string;\n}\n\n/**\n * A RainbowKit wallet for Topaz ID. Drop into `connectorsForWallets`:\n *\n * ```ts\n * connectorsForWallets(\n * [{ groupName: \"Sign in\", wallets: [topazIdWallet()] }],\n * { appName: \"Your App\", projectId: WC_PROJECT_ID },\n * );\n * ```\n */\nexport function topazIdWallet(options: TopazIdConnectorOptions = {}) {\n return toPrivyWallet({\n id: options.appId ?? TOPAZ_ID_APP_ID,\n name: TOPAZ_ID_NAME,\n iconUrl: options.iconUrl ?? TOPAZ_ID_ICON_URL,\n });\n}\n\n/**\n * A plain wagmi connector for Topaz ID — no RainbowKit required. Add to\n * `createConfig({ connectors: [topazIdConnector()] })`.\n */\nexport function topazIdConnector(options: TopazIdConnectorOptions = {}) {\n return toPrivyWalletConnector({\n id: options.appId ?? TOPAZ_ID_APP_ID,\n name: TOPAZ_ID_NAME,\n iconUrl: options.iconUrl ?? TOPAZ_ID_ICON_URL,\n });\n}\n"]}
package/dist/react.cjs ADDED
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var reactQuery = require('@tanstack/react-query');
4
+
5
+ // src/react.ts
6
+
7
+ // src/constants.ts
8
+ var TOPAZ_ID_BASE_URL = "https://id.topazdex.com";
9
+
10
+ // src/profile.ts
11
+ async function fetchTopazIdProfile(wallet, options = {}) {
12
+ const base = options.baseUrl ?? TOPAZ_ID_BASE_URL;
13
+ const res = await fetch(`${base}/api/v1/profile/${wallet}`, {
14
+ signal: options.signal
15
+ });
16
+ if (!res.ok) return null;
17
+ return await res.json();
18
+ }
19
+
20
+ // src/react.ts
21
+ function useTopazIdProfile(wallet, options = {}) {
22
+ return reactQuery.useQuery({
23
+ queryKey: ["topaz-id-profile", wallet?.toLowerCase()],
24
+ queryFn: ({ signal }) => fetchTopazIdProfile(wallet, {
25
+ baseUrl: options.baseUrl,
26
+ signal
27
+ }),
28
+ enabled: Boolean(wallet),
29
+ staleTime: options.staleTime ?? 6e4
30
+ });
31
+ }
32
+
33
+ exports.useTopazIdProfile = useTopazIdProfile;
34
+ //# sourceMappingURL=react.cjs.map
35
+ //# sourceMappingURL=react.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts","../src/profile.ts","../src/react.ts"],"names":["useQuery"],"mappings":";;;;;;;AAWO,IAAM,iBAAA,GAAoB,yBAAA;;;ACuBjC,eAAsB,mBAAA,CACpB,MAAA,EACA,OAAA,GAAsC,EAAC,EACP;AAChC,EAAA,MAAM,IAAA,GAAO,QAAQ,OAAA,IAAW,iBAAA;AAChC,EAAA,MAAM,MAAM,MAAM,KAAA,CAAM,GAAG,IAAI,CAAA,gBAAA,EAAmB,MAAM,CAAA,CAAA,EAAI;AAAA,IAC1D,QAAQ,OAAA,CAAQ;AAAA,GACjB,CAAA;AACD,EAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,OAAO,IAAA;AACpB,EAAA,OAAQ,MAAM,IAAI,IAAA,EAAK;AACzB;;;AChCO,SAAS,iBAAA,CACd,MAAA,EACA,OAAA,GAAoC,EAAC,EACrC;AACA,EAAA,OAAOA,mBAAA,CAAgC;AAAA,IACrC,QAAA,EAAU,CAAC,kBAAA,EAAoB,MAAA,EAAQ,aAAa,CAAA;AAAA,IACpD,SAAS,CAAC,EAAE,MAAA,EAAO,KACjB,oBAAoB,MAAA,EAAkB;AAAA,MACpC,SAAS,OAAA,CAAQ,OAAA;AAAA,MACjB;AAAA,KACD,CAAA;AAAA,IACH,OAAA,EAAS,QAAQ,MAAM,CAAA;AAAA,IACvB,SAAA,EAAW,QAAQ,SAAA,IAAa;AAAA,GACjC,CAAA;AACH","file":"react.cjs","sourcesContent":["/**\n * Topaz ID's PUBLIC Privy app id. This is the provider app id partners reference\n * to surface Topaz ID's global wallet — it is safe to ship in client code.\n */\nexport const TOPAZ_ID_APP_ID = \"cmpt1zsgh00rs0cld1hgqc0v7\";\n\nexport const TOPAZ_ID_NAME = \"Topaz ID\";\n\nexport const TOPAZ_ID_ICON_URL =\n \"https://id.topazdex.com/brand/topaz-logo.png\";\n\nexport const TOPAZ_ID_BASE_URL = \"https://id.topazdex.com\";\n","import { TOPAZ_ID_BASE_URL } from \"./constants\";\n\n/** Public profile shape returned by `GET /api/v1/profile/{wallet}`. */\nexport interface TopazIdProfile {\n wallet: string;\n found: boolean;\n name: string | null;\n description: string | null;\n handle: string | null;\n /** Absolute avatar URL, or null when the wallet has no avatar. */\n image: string | null;\n /** Absolute banner URL, or null. */\n banner: string | null;\n /** \"#rrggbb\" accent, or null. */\n accent: string | null;\n theme: string;\n links?: Record<string, unknown>;\n showcase?: Record<string, unknown>;\n followers?: number;\n following?: number;\n updatedAt: string | null;\n}\n\nexport interface FetchTopazIdProfileOptions {\n /** Override the Topaz ID base URL (defaults to https://id.topazdex.com). */\n baseUrl?: string;\n signal?: AbortSignal;\n}\n\n/**\n * Fetch a wallet's public Topaz ID profile. Reads are public and CORS-open — no\n * auth, no signature. Returns `null` on a network/HTTP failure; a wallet with no\n * profile resolves to an object with `found: false`.\n */\nexport async function fetchTopazIdProfile(\n wallet: string,\n options: FetchTopazIdProfileOptions = {},\n): Promise<TopazIdProfile | null> {\n const base = options.baseUrl ?? TOPAZ_ID_BASE_URL;\n const res = await fetch(`${base}/api/v1/profile/${wallet}`, {\n signal: options.signal,\n });\n if (!res.ok) return null;\n return (await res.json()) as TopazIdProfile;\n}\n\nexport function shortenAddress(wallet: string): string {\n return `${wallet.slice(0, 6)}…${wallet.slice(-4)}`;\n}\n\n/** Best display label: `@handle` → name → shortened address. */\nexport function displayNameForWallet(\n profile: TopazIdProfile | null,\n wallet: string,\n): string {\n if (profile?.handle) return `@${profile.handle}`;\n if (profile?.name) return profile.name;\n return shortenAddress(wallet);\n}\n\n/** Avatar URL from the profile, or your `fallback` when there is none. */\nexport function avatarForWallet(\n profile: TopazIdProfile | null,\n fallback = \"\",\n): string {\n return profile?.image ?? fallback;\n}\n","import { useQuery } from \"@tanstack/react-query\";\nimport { fetchTopazIdProfile, type TopazIdProfile } from \"./profile\";\n\nexport interface UseTopazIdProfileOptions {\n baseUrl?: string;\n staleTime?: number;\n}\n\n/**\n * React Query hook for a wallet's Topaz ID profile. Disabled until `wallet` is\n * defined; cached per lowercased address.\n */\nexport function useTopazIdProfile(\n wallet: string | undefined,\n options: UseTopazIdProfileOptions = {},\n) {\n return useQuery<TopazIdProfile | null>({\n queryKey: [\"topaz-id-profile\", wallet?.toLowerCase()],\n queryFn: ({ signal }) =>\n fetchTopazIdProfile(wallet as string, {\n baseUrl: options.baseUrl,\n signal,\n }),\n enabled: Boolean(wallet),\n staleTime: options.staleTime ?? 60_000,\n });\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import { T as TopazIdProfile } from './profile-C6bkM1cP.cjs';
3
+
4
+ interface UseTopazIdProfileOptions {
5
+ baseUrl?: string;
6
+ staleTime?: number;
7
+ }
8
+ /**
9
+ * React Query hook for a wallet's Topaz ID profile. Disabled until `wallet` is
10
+ * defined; cached per lowercased address.
11
+ */
12
+ declare function useTopazIdProfile(wallet: string | undefined, options?: UseTopazIdProfileOptions): _tanstack_react_query.UseQueryResult<NoInfer<TopazIdProfile | null>, Error>;
13
+
14
+ export { type UseTopazIdProfileOptions, useTopazIdProfile };
@@ -0,0 +1,14 @@
1
+ import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import { T as TopazIdProfile } from './profile-C6bkM1cP.js';
3
+
4
+ interface UseTopazIdProfileOptions {
5
+ baseUrl?: string;
6
+ staleTime?: number;
7
+ }
8
+ /**
9
+ * React Query hook for a wallet's Topaz ID profile. Disabled until `wallet` is
10
+ * defined; cached per lowercased address.
11
+ */
12
+ declare function useTopazIdProfile(wallet: string | undefined, options?: UseTopazIdProfileOptions): _tanstack_react_query.UseQueryResult<NoInfer<TopazIdProfile | null>, Error>;
13
+
14
+ export { type UseTopazIdProfileOptions, useTopazIdProfile };
package/dist/react.js ADDED
@@ -0,0 +1,19 @@
1
+ import { fetchTopazIdProfile } from './chunk-NE4VWRG6.js';
2
+ import './chunk-7OXTIVNI.js';
3
+ import { useQuery } from '@tanstack/react-query';
4
+
5
+ function useTopazIdProfile(wallet, options = {}) {
6
+ return useQuery({
7
+ queryKey: ["topaz-id-profile", wallet?.toLowerCase()],
8
+ queryFn: ({ signal }) => fetchTopazIdProfile(wallet, {
9
+ baseUrl: options.baseUrl,
10
+ signal
11
+ }),
12
+ enabled: Boolean(wallet),
13
+ staleTime: options.staleTime ?? 6e4
14
+ });
15
+ }
16
+
17
+ export { useTopazIdProfile };
18
+ //# sourceMappingURL=react.js.map
19
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react.ts"],"names":[],"mappings":";;;;AAYO,SAAS,iBAAA,CACd,MAAA,EACA,OAAA,GAAoC,EAAC,EACrC;AACA,EAAA,OAAO,QAAA,CAAgC;AAAA,IACrC,QAAA,EAAU,CAAC,kBAAA,EAAoB,MAAA,EAAQ,aAAa,CAAA;AAAA,IACpD,SAAS,CAAC,EAAE,MAAA,EAAO,KACjB,oBAAoB,MAAA,EAAkB;AAAA,MACpC,SAAS,OAAA,CAAQ,OAAA;AAAA,MACjB;AAAA,KACD,CAAA;AAAA,IACH,OAAA,EAAS,QAAQ,MAAM,CAAA;AAAA,IACvB,SAAA,EAAW,QAAQ,SAAA,IAAa;AAAA,GACjC,CAAA;AACH","file":"react.js","sourcesContent":["import { useQuery } from \"@tanstack/react-query\";\nimport { fetchTopazIdProfile, type TopazIdProfile } from \"./profile\";\n\nexport interface UseTopazIdProfileOptions {\n baseUrl?: string;\n staleTime?: number;\n}\n\n/**\n * React Query hook for a wallet's Topaz ID profile. Disabled until `wallet` is\n * defined; cached per lowercased address.\n */\nexport function useTopazIdProfile(\n wallet: string | undefined,\n options: UseTopazIdProfileOptions = {},\n) {\n return useQuery<TopazIdProfile | null>({\n queryKey: [\"topaz-id-profile\", wallet?.toLowerCase()],\n queryFn: ({ signal }) =>\n fetchTopazIdProfile(wallet as string, {\n baseUrl: options.baseUrl,\n signal,\n }),\n enabled: Boolean(wallet),\n staleTime: options.staleTime ?? 60_000,\n });\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@topazdex/id-connect",
3
+ "version": "0.1.0",
4
+ "description": "Add Topaz ID — a BNB Chain global wallet — to your dapp in one line.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "packageManager": "yarn@4.12.0",
9
+ "engines": {
10
+ "node": ">=18"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/topazdex/topaz-id-connect.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/topazdex/topaz-id-connect/issues"
18
+ },
19
+ "homepage": "https://id.topazdex.com/developers",
20
+ "keywords": [
21
+ "topaz",
22
+ "topaz-id",
23
+ "privy",
24
+ "global-wallet",
25
+ "cross-app",
26
+ "wagmi",
27
+ "rainbowkit",
28
+ "bnb-chain",
29
+ "wallet"
30
+ ],
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js",
38
+ "require": "./dist/index.cjs"
39
+ },
40
+ "./rainbow-kit": {
41
+ "types": "./dist/rainbow-kit.d.ts",
42
+ "import": "./dist/rainbow-kit.js",
43
+ "require": "./dist/rainbow-kit.cjs"
44
+ },
45
+ "./react": {
46
+ "types": "./dist/react.d.ts",
47
+ "import": "./dist/react.js",
48
+ "require": "./dist/react.cjs"
49
+ }
50
+ },
51
+ "scripts": {
52
+ "build": "tsup",
53
+ "dev": "tsup --watch",
54
+ "typecheck": "tsc --noEmit",
55
+ "prepublishOnly": "yarn build"
56
+ },
57
+ "peerDependencies": {
58
+ "@privy-io/cross-app-connect": "^0.5.0",
59
+ "@rainbow-me/rainbowkit": "^2.2.3",
60
+ "@tanstack/react-query": "^5",
61
+ "react": "^18 || ^19",
62
+ "viem": "^2",
63
+ "wagmi": "^2"
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "@rainbow-me/rainbowkit": {
67
+ "optional": true
68
+ },
69
+ "@tanstack/react-query": {
70
+ "optional": true
71
+ },
72
+ "react": {
73
+ "optional": true
74
+ },
75
+ "viem": {
76
+ "optional": true
77
+ },
78
+ "wagmi": {
79
+ "optional": true
80
+ }
81
+ },
82
+ "devDependencies": {
83
+ "@privy-io/cross-app-connect": "^0.5.12",
84
+ "@rainbow-me/rainbowkit": "^2.2.3",
85
+ "@tanstack/react-query": "^5.59.0",
86
+ "@types/react": "^19.0.0",
87
+ "react": "^19.0.0",
88
+ "tsup": "^8.3.0",
89
+ "typescript": "^5.6.0",
90
+ "viem": "2.52.0",
91
+ "wagmi": "^2.14.0"
92
+ },
93
+ "publishConfig": {
94
+ "access": "public"
95
+ }
96
+ }