@glyphteck/veyl 0.75.1 → 0.77.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.
@@ -62,6 +62,9 @@ var ACCOUNT_CONNECTION_SLOW_MS = 4 * MS_PER_SECOND;
62
62
  var ACCOUNT_CONNECTION_UNAVAILABLE_MS = 15 * MS_PER_SECOND;
63
63
  var ACCOUNT_CONNECTION_RETRY_MIN_MS = MS_PER_SECOND;
64
64
  var ACCOUNT_CONNECTION_RETRY_MAX_MS = 30 * MS_PER_SECOND;
65
+ var TICKET_MESSAGE_LIMIT = 4000;
66
+ var TICKET_ATTACHMENT_LIMIT = 3;
67
+ var TICKET_ATTACHMENT_MAX_BYTES = 5 * MIB_BYTES;
65
68
  var AUTOLOCK_MIN_MINUTES = 1;
66
69
  var AUTOLOCK_MAX_MINUTES = 60;
67
70
  var BTC_PRICE_FALLBACK = 80000;
@@ -69,6 +72,8 @@ var CHAT_MESSAGE_EDIT_WINDOW_MS = 10 * MINUTE_MS;
69
72
  var CHAT_SEND_CONNECTION_WAIT_MS = 30 * MS_PER_SECOND;
70
73
  var CALL_SPEAKING_THRESHOLD = 0.02;
71
74
  var CALL_SPEAKING_HOLD_MS = 320;
75
+ var WEB_LAYOUT_SAVE_DELAY_MS = 2 * MS_PER_SECOND;
76
+ var WEB_CHAT_LAYOUT_LIMIT = 32;
72
77
  var LOCAL_MEDIA_CACHE_MAX_BYTES = 512 * MIB_BYTES;
73
78
  var LOCAL_PROFILE_CACHE_MAX_ITEMS = 500;
74
79
  var LOCAL_PROFILE_CACHE_MAX_AGE_MS = 30 * DAY_MS;
@@ -177,6 +182,7 @@ var WALLET_PENDING_TRANSFER_CLAIM_COOLDOWN_MS = 15 * MS_PER_SECOND;
177
182
  var WALLET_SDK_BACKGROUND_QUIET_MS = MS_PER_SECOND;
178
183
  var WALLET_RECENT_TRANSFER_LIMIT = 100;
179
184
  var WALLET_TRANSFER_PAGE_LIMIT = 100;
185
+ var WALLET_TOKEN_HISTORY_PAGE_SIZE = 50;
180
186
  var WALLET_TRANSFER_FETCH_THROTTLE_MS = 150;
181
187
  var WALLET_PENDING_TRANSFER_CLAIM_RETRY_MS = 3 * MS_PER_SECOND;
182
188
  var WALLET_SENT_TRANSFER_REFRESH_DELAY_MS = 3 * MS_PER_SECOND;
package/dist/auth.js CHANGED
@@ -128,6 +128,158 @@ function hasAgreement(user, contract = CURRENT_AGREEMENT) {
128
128
  return isAgreementAccepted(user?.agreement, contract);
129
129
  }
130
130
 
131
+ // ../../core/crypto/core.js
132
+ "use client";
133
+ var encoder = new TextEncoder;
134
+ var decoder = new TextDecoder;
135
+ var MEM_KIB = 32 * 1024;
136
+ function randomBytes(length) {
137
+ const out = new Uint8Array(length);
138
+ if (globalThis.crypto?.getRandomValues) {
139
+ globalThis.crypto.getRandomValues(out);
140
+ return out;
141
+ }
142
+ throw new Error("crypto.getRandomValues is not available in this environment");
143
+ }
144
+ function toBytes(value, label = "bytes") {
145
+ if (value instanceof Uint8Array) {
146
+ return value;
147
+ }
148
+ if (typeof value === "string") {
149
+ return encoder.encode(value);
150
+ }
151
+ if (value instanceof ArrayBuffer) {
152
+ return new Uint8Array(value);
153
+ }
154
+ if (ArrayBuffer.isView(value)) {
155
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
156
+ }
157
+ throw new Error(`Invalid ${label}`);
158
+ }
159
+ function toBytes32(k, label = "key") {
160
+ if (k instanceof Uint8Array) {
161
+ if (k.length !== 32)
162
+ throw new Error(`Invalid ${label} key length`);
163
+ return k;
164
+ }
165
+ if (typeof k === "string") {
166
+ return fromHex(k, label);
167
+ }
168
+ throw new Error(`${label} key must be Uint8Array or 64-char hex`);
169
+ }
170
+ function toHex(value) {
171
+ return Array.from(toBytes(value)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
172
+ }
173
+ function fromHexBytes(hex, label = "hex") {
174
+ if (typeof hex !== "string" || hex.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(hex)) {
175
+ throw new Error(`Invalid ${label} hex`);
176
+ }
177
+ const out = new Uint8Array(hex.length / 2);
178
+ for (let i = 0;i < out.length; i += 1) {
179
+ out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
180
+ }
181
+ return out;
182
+ }
183
+ function fromHex(hex, label = "hex") {
184
+ const bytes = fromHexBytes(hex, label);
185
+ if (bytes.length !== 32) {
186
+ throw new Error(`Invalid ${label} hex`);
187
+ }
188
+ return bytes;
189
+ }
190
+ function cleanBytes(...values) {
191
+ for (const value of values) {
192
+ try {
193
+ value?.fill?.(0);
194
+ } catch {}
195
+ }
196
+ }
197
+
198
+ // ../../core/crypto/base64.js
199
+ "use client";
200
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
201
+ var VALUE_BY_CHAR = new Map([...ALPHABET].map((char, index) => [char, index]));
202
+ function bytesBase64Url(value, label = "base64url bytes") {
203
+ const bytes = toBytes(value, label);
204
+ let output = "";
205
+ for (let index = 0;index < bytes.length; index += 3) {
206
+ const a = bytes[index];
207
+ const hasB = index + 1 < bytes.length;
208
+ const hasC = index + 2 < bytes.length;
209
+ const b = hasB ? bytes[index + 1] : 0;
210
+ const c = hasC ? bytes[index + 2] : 0;
211
+ output += ALPHABET[a >>> 2];
212
+ output += ALPHABET[(a & 3) << 4 | b >>> 4];
213
+ if (hasB)
214
+ output += ALPHABET[(b & 15) << 2 | c >>> 6];
215
+ if (hasC)
216
+ output += ALPHABET[c & 63];
217
+ }
218
+ return output;
219
+ }
220
+ function base64UrlBytes(value, label = "base64url") {
221
+ const text = typeof value === "string" ? value.trim() : "";
222
+ if (!text || text.length % 4 === 1 || !/^[A-Za-z0-9_-]+$/u.test(text)) {
223
+ throw new Error(`invalid ${label}`);
224
+ }
225
+ const output = new Uint8Array(Math.floor(text.length * 6 / 8));
226
+ let bits = 0;
227
+ let bitCount = 0;
228
+ let offset = 0;
229
+ for (const char of text) {
230
+ const next = VALUE_BY_CHAR.get(char);
231
+ if (next == null)
232
+ throw new Error(`invalid ${label}`);
233
+ bits = bits << 6 | next;
234
+ bitCount += 6;
235
+ if (bitCount >= 8) {
236
+ bitCount -= 8;
237
+ output[offset++] = bits >>> bitCount & 255;
238
+ bits &= bitCount ? (1 << bitCount) - 1 : 0;
239
+ }
240
+ }
241
+ return output;
242
+ }
243
+
244
+ // ../../core/passkeyproof.js
245
+ function binary(value, label) {
246
+ if (typeof value === "string") {
247
+ const bytes = base64UrlBytes(value, label);
248
+ if (bytesBase64Url(bytes) !== value) {
249
+ cleanBytes(bytes);
250
+ throw new Error(`invalid ${label}`);
251
+ }
252
+ return bytes;
253
+ }
254
+ return toBytes(value, label);
255
+ }
256
+ function encoded(value, label) {
257
+ return bytesBase64Url(binary(value, label));
258
+ }
259
+ function passkeyProof(credential) {
260
+ if (credential?.type !== "public-key" || !credential.response) {
261
+ throw new Error("invalid passkey credential");
262
+ }
263
+ const rawId = encoded(credential.rawId, "passkey id");
264
+ if (!rawId || credential.id !== rawId)
265
+ throw new Error("passkey id mismatch");
266
+ const source = credential.response;
267
+ const response = {
268
+ clientDataJSON: encoded(source.clientDataJSON, "passkey client data")
269
+ };
270
+ if (source.attestationObject != null) {
271
+ response.attestationObject = encoded(source.attestationObject, "passkey attestation");
272
+ const transports = typeof source.getTransports === "function" ? source.getTransports() : source.transports;
273
+ if (Array.isArray(transports))
274
+ response.transports = transports.filter((value) => typeof value === "string");
275
+ } else {
276
+ response.authenticatorData = encoded(source.authenticatorData, "passkey authenticator data");
277
+ response.signature = encoded(source.signature, "passkey signature");
278
+ response.userHandle = source.userHandle == null ? null : encoded(source.userHandle, "passkey user handle");
279
+ }
280
+ return { id: rawId, rawId, type: "public-key", response };
281
+ }
282
+
131
283
  // ../../core/origins.js
132
284
  var ROOT_DOMAIN = "glyphteck.com";
133
285
  var VEYL_DEV_WEB_PORT_MIN = 3000;
@@ -139,7 +291,8 @@ var domains = Object.freeze({
139
291
  veylDev: `dev.veyl.${ROOT_DOMAIN}`,
140
292
  live: `live.veyl.${ROOT_DOMAIN}`,
141
293
  liveDev: `live.dev.veyl.${ROOT_DOMAIN}`,
142
- bitcoin: `bitcoin.veyl.${ROOT_DOMAIN}`
294
+ bitcoin: `bitcoin.veyl.${ROOT_DOMAIN}`,
295
+ bitcoinHistory: `history.veyl.${ROOT_DOMAIN}`
143
296
  });
144
297
  function getVeylDevWebOrigin(port) {
145
298
  const value = Number(port);
@@ -161,6 +314,7 @@ var liveEndpoints = Object.freeze({
161
314
  dev: `wss://${domains.liveDev}`
162
315
  });
163
316
  var bitcoinEndpoint = `https://${domains.bitcoin}/current`;
317
+ var bitcoinHistoryEndpoint = `https://${domains.bitcoinHistory}`;
164
318
  var appDomains = Object.freeze([
165
319
  domains.veyl
166
320
  ]);
@@ -170,12 +324,14 @@ var appLinkDomains = Object.freeze([
170
324
  ]);
171
325
 
172
326
  // ../../product/links.js
327
+ var APP_STORE_ID = "6782957925";
173
328
  var links = Object.freeze({
174
329
  root: origins.root,
175
330
  rootDev: origins.rootDev,
176
331
  veyl: origins.veyl,
177
332
  veylDev: origins.veylDev,
178
333
  veylDevWeb: origins.veylDevWeb,
334
+ appStore: `https://apps.apple.com/app/id${APP_STORE_ID}`,
179
335
  terms: `${origins.veyl}/terms#terms`,
180
336
  contact: `mailto:contact@${ROOT_DOMAIN}`,
181
337
  regtestFaucet: "https://app.lightspark.com/regtest-faucet"
@@ -492,14 +648,14 @@ function openAuth(options = {}) {
492
648
  const result = await requireMethod(ceremony.create, "passkey creation")(publicKeyOptions, operation);
493
649
  if (!result)
494
650
  throw new Error("no credential received");
495
- return result;
651
+ return passkeyProof(result);
496
652
  }
497
653
  async function getCredential(publicKeyOptions, operation = {}) {
498
654
  operation.onPrompt?.();
499
655
  const result = await requireMethod(ceremony.get, "passkey verification")(publicKeyOptions, operation);
500
656
  if (!result)
501
657
  throw new Error("no assertion received");
502
- return result;
658
+ return passkeyProof(result);
503
659
  }
504
660
  async function register(operation = {}, tokenOnly = false) {
505
661
  try {