@stellar-snaps/sdk 0.3.1 → 0.3.2

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.mjs CHANGED
@@ -154,6 +154,74 @@ async function deleteSnap(id, creator, options = {}) {
154
154
  }
155
155
  }
156
156
 
157
+ // src/snap-modal.ts
158
+ var MODAL_ID = "stellar-snap-modal";
159
+ var IFRAME_ID = "stellar-snap-modal-iframe";
160
+ function isBrowser() {
161
+ return typeof document !== "undefined" && typeof window !== "undefined";
162
+ }
163
+ function openSnapModal(snapUrl, options = {}) {
164
+ if (!isBrowser()) return;
165
+ closeSnapModal();
166
+ const { width = 420, height = 560, onClose } = options;
167
+ const overlay = document.createElement("div");
168
+ overlay.id = MODAL_ID;
169
+ overlay.setAttribute("role", "dialog");
170
+ overlay.setAttribute("aria-modal", "true");
171
+ overlay.setAttribute("aria-label", "Stellar Snap payment");
172
+ const styles = {
173
+ position: "fixed",
174
+ inset: "0",
175
+ zIndex: "2147483647",
176
+ display: "flex",
177
+ alignItems: "center",
178
+ justifyContent: "center",
179
+ backgroundColor: "rgba(0, 0, 0, 0.6)",
180
+ padding: "20px",
181
+ boxSizing: "border-box"
182
+ };
183
+ Object.assign(overlay.style, styles);
184
+ const container = document.createElement("div");
185
+ container.style.position = "relative";
186
+ container.style.width = `${width}px`;
187
+ container.style.maxWidth = "100%";
188
+ container.style.height = `${height}px`;
189
+ container.style.maxHeight = "90vh";
190
+ container.style.backgroundColor = "rgb(23, 23, 23)";
191
+ container.style.borderRadius = "16px";
192
+ container.style.boxShadow = "0 25px 50px -12px rgba(0, 0, 0, 0.5)";
193
+ container.style.overflow = "hidden";
194
+ const closeBtn = document.createElement("button");
195
+ closeBtn.type = "button";
196
+ closeBtn.setAttribute("aria-label", "Close");
197
+ closeBtn.textContent = "\xD7";
198
+ closeBtn.style.cssText = "position:absolute;top:12px;right:12px;z-index:10;width:32px;height:32px;border:none;border-radius:8px;background:rgba(255,255,255,0.1);color:#e5e5e5;font-size:24px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;";
199
+ closeBtn.onclick = () => {
200
+ closeSnapModal();
201
+ onClose?.();
202
+ };
203
+ const iframe = document.createElement("iframe");
204
+ iframe.id = IFRAME_ID;
205
+ iframe.src = snapUrl;
206
+ iframe.title = "Stellar Snap payment";
207
+ iframe.style.cssText = "width:100%;height:100%;border:none;border-radius:16px;";
208
+ container.appendChild(closeBtn);
209
+ container.appendChild(iframe);
210
+ overlay.appendChild(container);
211
+ overlay.addEventListener("click", (e) => {
212
+ if (e.target === overlay) {
213
+ closeSnapModal();
214
+ onClose?.();
215
+ }
216
+ });
217
+ document.body.appendChild(overlay);
218
+ }
219
+ function closeSnapModal() {
220
+ if (!isBrowser()) return;
221
+ const el = document.getElementById(MODAL_ID);
222
+ if (el) el.remove();
223
+ }
224
+
157
225
  // src/snap-id.ts
158
226
  var ALPHABET = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
159
227
  function generateSnapId(length = 8) {
@@ -1164,6 +1232,6 @@ function parseAddress(input) {
1164
1232
  throw new Error("Invalid address format");
1165
1233
  }
1166
1234
 
1167
- export { CACHE_HEADERS, CORS_HEADERS, EXPLORER_URLS, HORIZON_URLS, InvalidAddressError, InvalidAmountError, InvalidAssetError, InvalidUriError, NETWORK_PASSPHRASES2 as NETWORK_PASSPHRASES, POSTGRES_SCHEMA, SHORTENER_DOMAINS, SQLITE_SCHEMA, SnapApiError, SnapNotFoundError, SnapUnauthorizedError, StellarSnapError, addDomain, buildPaymentTransaction, buildUrl, connectFreighter, createAsset, createDiscoveryFile, createPaymentSnap, createRateLimiter, createRegistry, createSnap, createSnapObject, createTransactionSnap, deleteSnap, errorResponse, extractDomain, extractPath, extractSnapId, generateJsonLd, generateMetaTags, generateSnapId, getAccountUrl, getAssetUrl, getBlockedDomains, getDomainStatus, getFreighterNetwork, getOperationUrl, getSnap, getTransactionUrl, getVerifiedDomains, isDomainBlocked, isDomainVerified, isFreighterConnected, isShortenerUrl, isValidAmount, isValidAssetCode, isValidSnapId, isValidStellarAddress, listSnaps, matchUrlToRule, metaTagsToHtml, parseAddress, parseQueryParams, parseSnapUri, removeDomain, resolveUrl, resolveUrls, signWithFreighter, submitTransaction, successResponse, validateDiscoveryFile, validateRegistry, validateRequired, validateSnapInput };
1235
+ export { CACHE_HEADERS, CORS_HEADERS, EXPLORER_URLS, HORIZON_URLS, InvalidAddressError, InvalidAmountError, InvalidAssetError, InvalidUriError, NETWORK_PASSPHRASES2 as NETWORK_PASSPHRASES, POSTGRES_SCHEMA, SHORTENER_DOMAINS, SQLITE_SCHEMA, SnapApiError, SnapNotFoundError, SnapUnauthorizedError, StellarSnapError, addDomain, buildPaymentTransaction, buildUrl, closeSnapModal, connectFreighter, createAsset, createDiscoveryFile, createPaymentSnap, createRateLimiter, createRegistry, createSnap, createSnapObject, createTransactionSnap, deleteSnap, errorResponse, extractDomain, extractPath, extractSnapId, generateJsonLd, generateMetaTags, generateSnapId, getAccountUrl, getAssetUrl, getBlockedDomains, getDomainStatus, getFreighterNetwork, getOperationUrl, getSnap, getTransactionUrl, getVerifiedDomains, isDomainBlocked, isDomainVerified, isFreighterConnected, isShortenerUrl, isValidAmount, isValidAssetCode, isValidSnapId, isValidStellarAddress, listSnaps, matchUrlToRule, metaTagsToHtml, openSnapModal, parseAddress, parseQueryParams, parseSnapUri, removeDomain, resolveUrl, resolveUrls, signWithFreighter, submitTransaction, successResponse, validateDiscoveryFile, validateRegistry, validateRequired, validateSnapInput };
1168
1236
  //# sourceMappingURL=index.mjs.map
1169
1237
  //# sourceMappingURL=index.mjs.map