@pooflabs/core 0.0.2 → 0.0.4
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 +1 -1
- package/dist/index.js +266 -157
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +266 -158
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/utils/auth-api.d.ts +1 -0
- package/dist/utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpDevnet-program.d.ts +497 -64
- package/dist/utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpMainnet-program.d.ts +497 -64
- package/dist/utils/sol/sol-utils.d.ts +1 -1
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from './types';
|
|
|
6
6
|
export { getIdToken } from './utils/utils';
|
|
7
7
|
export { WebSessionManager } from './utils/web-session-manager';
|
|
8
8
|
export { ServerSessionManager } from './utils/server-session-manager';
|
|
9
|
-
export { createSessionWithPrivy, createSessionWithSignature, refreshSession, signSessionCreateMessage } from './utils/auth-api';
|
|
9
|
+
export { createSessionWithPrivy, createSessionWithSignature, refreshSession, signSessionCreateMessage, genAuthNonce } from './utils/auth-api';
|
|
10
10
|
export { Tarobase as Tarobase6 } from './utils/sol/taro6CvKqwrYrDc16ufYgzQ2NZcyyVKStffbtudrhRuDevnet-program';
|
|
11
11
|
export { Tarobase as TarobasePoof } from './utils/sol/poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZpMainnet-program';
|
|
12
12
|
export { buildSetDocumentsTransaction, convertRemainingAccounts, RemainingAccount, genSolanaMessage } from './utils/sol/sol-utils';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
4
|
var web3_js = require('@solana/web3.js');
|
|
5
|
-
var require$$0 = require('
|
|
5
|
+
var require$$0 = require('buffer');
|
|
6
|
+
var require$$0$1 = require('crypto');
|
|
6
7
|
var anchor = require('@coral-xyz/anchor');
|
|
7
8
|
|
|
8
9
|
function _interopNamespaceDefault(e) {
|
|
@@ -37,6 +38,15 @@ async function getAxiosAuthClient() {
|
|
|
37
38
|
}
|
|
38
39
|
return axiosClient;
|
|
39
40
|
}
|
|
41
|
+
async function genAuthNonce() {
|
|
42
|
+
const client = await getAxiosAuthClient();
|
|
43
|
+
const config = await getConfig();
|
|
44
|
+
const appId = config.appId;
|
|
45
|
+
const response = await client.post('/auth/nonce', {
|
|
46
|
+
appId
|
|
47
|
+
});
|
|
48
|
+
return response.data.nonce;
|
|
49
|
+
}
|
|
40
50
|
async function createSessionWithSignature(address, message, signature) {
|
|
41
51
|
const client = await getAxiosAuthClient();
|
|
42
52
|
const config = await getConfig();
|
|
@@ -108,7 +118,6 @@ class WebSessionManager {
|
|
|
108
118
|
/* ---------- validate app-id ---------- */
|
|
109
119
|
const config = await getConfig();
|
|
110
120
|
if (sessionObj.appId && sessionObj.appId !== config.appId) {
|
|
111
|
-
console.warn("Session appId mismatch. Stored session belongs to a different app. Logging out.");
|
|
112
121
|
this.clearSession();
|
|
113
122
|
return null;
|
|
114
123
|
}
|
|
@@ -133,7 +142,6 @@ class WebSessionManager {
|
|
|
133
142
|
}
|
|
134
143
|
}
|
|
135
144
|
catch (err) {
|
|
136
|
-
console.error("Error decoding access token:", err);
|
|
137
145
|
return null;
|
|
138
146
|
}
|
|
139
147
|
return { address: sessionObj.address, session: sessionObj };
|
|
@@ -184,7 +192,6 @@ class WebSessionManager {
|
|
|
184
192
|
/* ---------- app-id guard ---------- */
|
|
185
193
|
const config = await getConfig();
|
|
186
194
|
if (sessionObj.appId && sessionObj.appId !== config.appId) {
|
|
187
|
-
console.warn("Session appId mismatch during token refresh. Logging out.");
|
|
188
195
|
this.clearSession();
|
|
189
196
|
return;
|
|
190
197
|
}
|
|
@@ -196,137 +203,235 @@ class WebSessionManager {
|
|
|
196
203
|
}
|
|
197
204
|
WebSessionManager.TAROBASE_SESSION_STORAGE_KEY = "tarobase_session_storage";
|
|
198
205
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
202
|
-
// Distributed under the MIT software license, see the accompanying
|
|
203
|
-
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
204
|
-
function base (ALPHABET) {
|
|
205
|
-
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
206
|
-
const BASE_MAP = new Uint8Array(256);
|
|
207
|
-
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
208
|
-
BASE_MAP[j] = 255;
|
|
209
|
-
}
|
|
210
|
-
for (let i = 0; i < ALPHABET.length; i++) {
|
|
211
|
-
const x = ALPHABET.charAt(i);
|
|
212
|
-
const xc = x.charCodeAt(0);
|
|
213
|
-
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
214
|
-
BASE_MAP[xc] = i;
|
|
215
|
-
}
|
|
216
|
-
const BASE = ALPHABET.length;
|
|
217
|
-
const LEADER = ALPHABET.charAt(0);
|
|
218
|
-
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
219
|
-
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
220
|
-
function encode (source) {
|
|
221
|
-
// eslint-disable-next-line no-empty
|
|
222
|
-
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
223
|
-
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
224
|
-
} else if (Array.isArray(source)) {
|
|
225
|
-
source = Uint8Array.from(source);
|
|
226
|
-
}
|
|
227
|
-
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
228
|
-
if (source.length === 0) { return '' }
|
|
229
|
-
// Skip & count leading zeroes.
|
|
230
|
-
let zeroes = 0;
|
|
231
|
-
let length = 0;
|
|
232
|
-
let pbegin = 0;
|
|
233
|
-
const pend = source.length;
|
|
234
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
|
235
|
-
pbegin++;
|
|
236
|
-
zeroes++;
|
|
237
|
-
}
|
|
238
|
-
// Allocate enough space in big-endian base58 representation.
|
|
239
|
-
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
240
|
-
const b58 = new Uint8Array(size);
|
|
241
|
-
// Process the bytes.
|
|
242
|
-
while (pbegin !== pend) {
|
|
243
|
-
let carry = source[pbegin];
|
|
244
|
-
// Apply "b58 = b58 * 256 + ch".
|
|
245
|
-
let i = 0;
|
|
246
|
-
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
247
|
-
carry += (256 * b58[it1]) >>> 0;
|
|
248
|
-
b58[it1] = (carry % BASE) >>> 0;
|
|
249
|
-
carry = (carry / BASE) >>> 0;
|
|
250
|
-
}
|
|
251
|
-
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
252
|
-
length = i;
|
|
253
|
-
pbegin++;
|
|
254
|
-
}
|
|
255
|
-
// Skip leading zeroes in base58 result.
|
|
256
|
-
let it2 = size - length;
|
|
257
|
-
while (it2 !== size && b58[it2] === 0) {
|
|
258
|
-
it2++;
|
|
259
|
-
}
|
|
260
|
-
// Translate the result into a string.
|
|
261
|
-
let str = LEADER.repeat(zeroes);
|
|
262
|
-
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
263
|
-
return str
|
|
264
|
-
}
|
|
265
|
-
function decodeUnsafe (source) {
|
|
266
|
-
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
267
|
-
if (source.length === 0) { return new Uint8Array() }
|
|
268
|
-
let psz = 0;
|
|
269
|
-
// Skip and count leading '1's.
|
|
270
|
-
let zeroes = 0;
|
|
271
|
-
let length = 0;
|
|
272
|
-
while (source[psz] === LEADER) {
|
|
273
|
-
zeroes++;
|
|
274
|
-
psz++;
|
|
275
|
-
}
|
|
276
|
-
// Allocate enough space in big-endian base256 representation.
|
|
277
|
-
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
278
|
-
const b256 = new Uint8Array(size);
|
|
279
|
-
// Process the characters.
|
|
280
|
-
while (psz < source.length) {
|
|
281
|
-
// Find code of next character
|
|
282
|
-
const charCode = source.charCodeAt(psz);
|
|
283
|
-
// Base map can not be indexed using char code
|
|
284
|
-
if (charCode > 255) { return }
|
|
285
|
-
// Decode character
|
|
286
|
-
let carry = BASE_MAP[charCode];
|
|
287
|
-
// Invalid character
|
|
288
|
-
if (carry === 255) { return }
|
|
289
|
-
let i = 0;
|
|
290
|
-
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
291
|
-
carry += (BASE * b256[it3]) >>> 0;
|
|
292
|
-
b256[it3] = (carry % 256) >>> 0;
|
|
293
|
-
carry = (carry / 256) >>> 0;
|
|
294
|
-
}
|
|
295
|
-
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
296
|
-
length = i;
|
|
297
|
-
psz++;
|
|
298
|
-
}
|
|
299
|
-
// Skip leading zeroes in b256.
|
|
300
|
-
let it4 = size - length;
|
|
301
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
302
|
-
it4++;
|
|
303
|
-
}
|
|
304
|
-
const vch = new Uint8Array(zeroes + (size - it4));
|
|
305
|
-
let j = zeroes;
|
|
306
|
-
while (it4 !== size) {
|
|
307
|
-
vch[j++] = b256[it4++];
|
|
308
|
-
}
|
|
309
|
-
return vch
|
|
310
|
-
}
|
|
311
|
-
function decode (string) {
|
|
312
|
-
const buffer = decodeUnsafe(string);
|
|
313
|
-
if (buffer) { return buffer }
|
|
314
|
-
throw new Error('Non-base' + BASE + ' character')
|
|
315
|
-
}
|
|
316
|
-
return {
|
|
317
|
-
encode,
|
|
318
|
-
decodeUnsafe,
|
|
319
|
-
decode
|
|
320
|
-
}
|
|
206
|
+
function getDefaultExportFromCjs (x) {
|
|
207
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
321
208
|
}
|
|
322
209
|
|
|
323
|
-
var
|
|
324
|
-
var bs58 = base(ALPHABET);
|
|
210
|
+
var safeBuffer = {exports: {}};
|
|
325
211
|
|
|
326
|
-
|
|
327
|
-
|
|
212
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
213
|
+
|
|
214
|
+
var hasRequiredSafeBuffer;
|
|
215
|
+
|
|
216
|
+
function requireSafeBuffer () {
|
|
217
|
+
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
218
|
+
hasRequiredSafeBuffer = 1;
|
|
219
|
+
(function (module, exports$1) {
|
|
220
|
+
/* eslint-disable node/no-deprecated-api */
|
|
221
|
+
var buffer = require$$0;
|
|
222
|
+
var Buffer = buffer.Buffer;
|
|
223
|
+
|
|
224
|
+
// alternative to using Object.keys for old browsers
|
|
225
|
+
function copyProps (src, dst) {
|
|
226
|
+
for (var key in src) {
|
|
227
|
+
dst[key] = src[key];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
231
|
+
module.exports = buffer;
|
|
232
|
+
} else {
|
|
233
|
+
// Copy properties from require('buffer')
|
|
234
|
+
copyProps(buffer, exports$1);
|
|
235
|
+
exports$1.Buffer = SafeBuffer;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
239
|
+
return Buffer(arg, encodingOrOffset, length)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
SafeBuffer.prototype = Object.create(Buffer.prototype);
|
|
243
|
+
|
|
244
|
+
// Copy static methods from Buffer
|
|
245
|
+
copyProps(Buffer, SafeBuffer);
|
|
246
|
+
|
|
247
|
+
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
248
|
+
if (typeof arg === 'number') {
|
|
249
|
+
throw new TypeError('Argument must not be a number')
|
|
250
|
+
}
|
|
251
|
+
return Buffer(arg, encodingOrOffset, length)
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
255
|
+
if (typeof size !== 'number') {
|
|
256
|
+
throw new TypeError('Argument must be a number')
|
|
257
|
+
}
|
|
258
|
+
var buf = Buffer(size);
|
|
259
|
+
if (fill !== undefined) {
|
|
260
|
+
if (typeof encoding === 'string') {
|
|
261
|
+
buf.fill(fill, encoding);
|
|
262
|
+
} else {
|
|
263
|
+
buf.fill(fill);
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
buf.fill(0);
|
|
267
|
+
}
|
|
268
|
+
return buf
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
SafeBuffer.allocUnsafe = function (size) {
|
|
272
|
+
if (typeof size !== 'number') {
|
|
273
|
+
throw new TypeError('Argument must be a number')
|
|
274
|
+
}
|
|
275
|
+
return Buffer(size)
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
279
|
+
if (typeof size !== 'number') {
|
|
280
|
+
throw new TypeError('Argument must be a number')
|
|
281
|
+
}
|
|
282
|
+
return buffer.SlowBuffer(size)
|
|
283
|
+
};
|
|
284
|
+
} (safeBuffer, safeBuffer.exports));
|
|
285
|
+
return safeBuffer.exports;
|
|
328
286
|
}
|
|
329
287
|
|
|
288
|
+
var src;
|
|
289
|
+
var hasRequiredSrc;
|
|
290
|
+
|
|
291
|
+
function requireSrc () {
|
|
292
|
+
if (hasRequiredSrc) return src;
|
|
293
|
+
hasRequiredSrc = 1;
|
|
294
|
+
// base-x encoding / decoding
|
|
295
|
+
// Copyright (c) 2018 base-x contributors
|
|
296
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
297
|
+
// Distributed under the MIT software license, see the accompanying
|
|
298
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
299
|
+
// @ts-ignore
|
|
300
|
+
var _Buffer = requireSafeBuffer().Buffer;
|
|
301
|
+
function base (ALPHABET) {
|
|
302
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
303
|
+
var BASE_MAP = new Uint8Array(256);
|
|
304
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
305
|
+
BASE_MAP[j] = 255;
|
|
306
|
+
}
|
|
307
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
|
308
|
+
var x = ALPHABET.charAt(i);
|
|
309
|
+
var xc = x.charCodeAt(0);
|
|
310
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
311
|
+
BASE_MAP[xc] = i;
|
|
312
|
+
}
|
|
313
|
+
var BASE = ALPHABET.length;
|
|
314
|
+
var LEADER = ALPHABET.charAt(0);
|
|
315
|
+
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
316
|
+
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
317
|
+
function encode (source) {
|
|
318
|
+
if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source); }
|
|
319
|
+
if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
|
|
320
|
+
if (source.length === 0) { return '' }
|
|
321
|
+
// Skip & count leading zeroes.
|
|
322
|
+
var zeroes = 0;
|
|
323
|
+
var length = 0;
|
|
324
|
+
var pbegin = 0;
|
|
325
|
+
var pend = source.length;
|
|
326
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
327
|
+
pbegin++;
|
|
328
|
+
zeroes++;
|
|
329
|
+
}
|
|
330
|
+
// Allocate enough space in big-endian base58 representation.
|
|
331
|
+
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
332
|
+
var b58 = new Uint8Array(size);
|
|
333
|
+
// Process the bytes.
|
|
334
|
+
while (pbegin !== pend) {
|
|
335
|
+
var carry = source[pbegin];
|
|
336
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
337
|
+
var i = 0;
|
|
338
|
+
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
339
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
340
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
341
|
+
carry = (carry / BASE) >>> 0;
|
|
342
|
+
}
|
|
343
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
344
|
+
length = i;
|
|
345
|
+
pbegin++;
|
|
346
|
+
}
|
|
347
|
+
// Skip leading zeroes in base58 result.
|
|
348
|
+
var it2 = size - length;
|
|
349
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
350
|
+
it2++;
|
|
351
|
+
}
|
|
352
|
+
// Translate the result into a string.
|
|
353
|
+
var str = LEADER.repeat(zeroes);
|
|
354
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
355
|
+
return str
|
|
356
|
+
}
|
|
357
|
+
function decodeUnsafe (source) {
|
|
358
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
359
|
+
if (source.length === 0) { return _Buffer.alloc(0) }
|
|
360
|
+
var psz = 0;
|
|
361
|
+
// Skip and count leading '1's.
|
|
362
|
+
var zeroes = 0;
|
|
363
|
+
var length = 0;
|
|
364
|
+
while (source[psz] === LEADER) {
|
|
365
|
+
zeroes++;
|
|
366
|
+
psz++;
|
|
367
|
+
}
|
|
368
|
+
// Allocate enough space in big-endian base256 representation.
|
|
369
|
+
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
370
|
+
var b256 = new Uint8Array(size);
|
|
371
|
+
// Process the characters.
|
|
372
|
+
while (psz < source.length) {
|
|
373
|
+
// Find code of next character
|
|
374
|
+
var charCode = source.charCodeAt(psz);
|
|
375
|
+
// Base map can not be indexed using char code
|
|
376
|
+
if (charCode > 255) { return }
|
|
377
|
+
// Decode character
|
|
378
|
+
var carry = BASE_MAP[charCode];
|
|
379
|
+
// Invalid character
|
|
380
|
+
if (carry === 255) { return }
|
|
381
|
+
var i = 0;
|
|
382
|
+
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
383
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
384
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
385
|
+
carry = (carry / 256) >>> 0;
|
|
386
|
+
}
|
|
387
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
388
|
+
length = i;
|
|
389
|
+
psz++;
|
|
390
|
+
}
|
|
391
|
+
// Skip leading zeroes in b256.
|
|
392
|
+
var it4 = size - length;
|
|
393
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
394
|
+
it4++;
|
|
395
|
+
}
|
|
396
|
+
var vch = _Buffer.allocUnsafe(zeroes + (size - it4));
|
|
397
|
+
vch.fill(0x00, 0, zeroes);
|
|
398
|
+
var j = zeroes;
|
|
399
|
+
while (it4 !== size) {
|
|
400
|
+
vch[j++] = b256[it4++];
|
|
401
|
+
}
|
|
402
|
+
return vch
|
|
403
|
+
}
|
|
404
|
+
function decode (string) {
|
|
405
|
+
var buffer = decodeUnsafe(string);
|
|
406
|
+
if (buffer) { return buffer }
|
|
407
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
408
|
+
}
|
|
409
|
+
return {
|
|
410
|
+
encode: encode,
|
|
411
|
+
decodeUnsafe: decodeUnsafe,
|
|
412
|
+
decode: decode
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
src = base;
|
|
416
|
+
return src;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
var bs58$1;
|
|
420
|
+
var hasRequiredBs58;
|
|
421
|
+
|
|
422
|
+
function requireBs58 () {
|
|
423
|
+
if (hasRequiredBs58) return bs58$1;
|
|
424
|
+
hasRequiredBs58 = 1;
|
|
425
|
+
var basex = requireSrc();
|
|
426
|
+
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
427
|
+
|
|
428
|
+
bs58$1 = basex(ALPHABET);
|
|
429
|
+
return bs58$1;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
var bs58Exports = requireBs58();
|
|
433
|
+
var bs58 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
|
|
434
|
+
|
|
330
435
|
function commonjsRequire(path) {
|
|
331
436
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
332
437
|
}
|
|
@@ -2717,7 +2822,7 @@ function requireNaclFast () {
|
|
|
2717
2822
|
});
|
|
2718
2823
|
} else if (typeof commonjsRequire !== 'undefined') {
|
|
2719
2824
|
// Node.js.
|
|
2720
|
-
crypto = require$$0;
|
|
2825
|
+
crypto = require$$0$1;
|
|
2721
2826
|
if (crypto && crypto.randomBytes) {
|
|
2722
2827
|
nacl.setPRNG(function(x, n) {
|
|
2723
2828
|
var i, v = crypto.randomBytes(n);
|
|
@@ -2789,7 +2894,7 @@ function requireBn () {
|
|
|
2789
2894
|
if (hasRequiredBn) return bn$1.exports;
|
|
2790
2895
|
hasRequiredBn = 1;
|
|
2791
2896
|
(function (module) {
|
|
2792
|
-
(function (module, exports) {
|
|
2897
|
+
(function (module, exports$1) {
|
|
2793
2898
|
|
|
2794
2899
|
// Utils
|
|
2795
2900
|
function assert (val, msg) {
|
|
@@ -2832,7 +2937,7 @@ function requireBn () {
|
|
|
2832
2937
|
if (typeof module === 'object') {
|
|
2833
2938
|
module.exports = BN;
|
|
2834
2939
|
} else {
|
|
2835
|
-
exports.BN = BN;
|
|
2940
|
+
exports$1.BN = BN;
|
|
2836
2941
|
}
|
|
2837
2942
|
|
|
2838
2943
|
BN.BN = BN;
|
|
@@ -6148,19 +6253,33 @@ var BN = /*@__PURE__*/getDefaultExportFromCjs(bnExports);
|
|
|
6148
6253
|
/* ------------------------------------------------------------------ */
|
|
6149
6254
|
/* RFC-4501 message */
|
|
6150
6255
|
/* ------------------------------------------------------------------ */
|
|
6151
|
-
async function genSolanaMessage(address) {
|
|
6256
|
+
async function genSolanaMessage(address, nonce) {
|
|
6152
6257
|
var _a, _b;
|
|
6153
|
-
/* Domain / origin aren
|
|
6258
|
+
/* Domain / origin aren't available server-side – fall back to envs
|
|
6154
6259
|
or simple placeholders. */
|
|
6155
6260
|
const domain = (_a = process.env.SESSION_DOMAIN) !== null && _a !== void 0 ? _a : "server";
|
|
6156
6261
|
const origin = (_b = process.env.SESSION_ORIGIN) !== null && _b !== void 0 ? _b : "server";
|
|
6157
6262
|
const statement = "Sign this message to authenticate with our application.";
|
|
6158
|
-
const
|
|
6263
|
+
const currentDate = new Date();
|
|
6264
|
+
const issuedAt = currentDate.toISOString();
|
|
6265
|
+
// If nonce is provided, include it and expiration time (for secure authentication)
|
|
6266
|
+
if (nonce) {
|
|
6267
|
+
const expirationDate = new Date(currentDate.getTime() + 5 * 60 * 1000);
|
|
6268
|
+
const expirationTime = expirationDate.toISOString();
|
|
6269
|
+
return `${statement}\n\n` +
|
|
6270
|
+
`Wallet address:\n${address}\n\n` +
|
|
6271
|
+
`Domain: ${domain}\n` +
|
|
6272
|
+
`Origin: ${origin}\n` +
|
|
6273
|
+
`Nonce: ${nonce}\n` +
|
|
6274
|
+
`Issued At: ${issuedAt}\n` +
|
|
6275
|
+
`Expiration Time: ${expirationTime}`;
|
|
6276
|
+
}
|
|
6277
|
+
// Backward compatible: without nonce (for server-side usage)
|
|
6159
6278
|
return `${statement}\n\n` +
|
|
6160
6279
|
`Wallet address:\n${address}\n\n` +
|
|
6161
6280
|
`Domain: ${domain}\n` +
|
|
6162
6281
|
`Origin: ${origin}\n` +
|
|
6163
|
-
`Issued At: ${
|
|
6282
|
+
`Issued At: ${issuedAt}`;
|
|
6164
6283
|
}
|
|
6165
6284
|
// ─────────────────────────────────────────────────────────────
|
|
6166
6285
|
// Serialization Helpers
|
|
@@ -6277,7 +6396,8 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
6277
6396
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
6278
6397
|
tx.recentBlockhash = blockhash;
|
|
6279
6398
|
if (lutKey == null) {
|
|
6280
|
-
const
|
|
6399
|
+
const isSurfnet = anchorProvider.connection.rpcEndpoint == "https://surfpool.fly.dev";
|
|
6400
|
+
const computeUnits = isSurfnet ? 1400000 : await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, []);
|
|
6281
6401
|
const computeBudgetIxOptimized = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
6282
6402
|
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
6283
6403
|
}); // 20% buffer
|
|
@@ -6287,7 +6407,8 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
6287
6407
|
const { value: table } = await connection.getAddressLookupTable(new web3_js.PublicKey(lutKey));
|
|
6288
6408
|
if (!table)
|
|
6289
6409
|
throw new Error('LUT not found after creation/extend');
|
|
6290
|
-
const
|
|
6410
|
+
const isSurfnet = anchorProvider.connection.rpcEndpoint == "https://surfpool.fly.dev";
|
|
6411
|
+
const computeUnits = isSurfnet ? 1400000 : await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, [table]);
|
|
6291
6412
|
const computeBudgetIxOptimized = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
6292
6413
|
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
6293
6414
|
}); // 20% buffer
|
|
@@ -6424,7 +6545,7 @@ function updateIdTokenAndAccessToken(idToken, accessToken) {
|
|
|
6424
6545
|
}
|
|
6425
6546
|
|
|
6426
6547
|
async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
6427
|
-
var _a, _b, _c, _d, _e, _f
|
|
6548
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6428
6549
|
const config = await getConfig();
|
|
6429
6550
|
async function executeRequest() {
|
|
6430
6551
|
const authHeader = await createAuthHeader(config.isServer);
|
|
@@ -6474,8 +6595,7 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
6474
6595
|
return { data: null, status: 404 };
|
|
6475
6596
|
}
|
|
6476
6597
|
if ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message) {
|
|
6477
|
-
|
|
6478
|
-
throw new Error((_j = (_h = error.response) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.message);
|
|
6598
|
+
throw new Error((_f = (_e = error.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.message);
|
|
6479
6599
|
}
|
|
6480
6600
|
throw error;
|
|
6481
6601
|
}
|
|
@@ -6516,8 +6636,6 @@ function init(newConfig) {
|
|
|
6516
6636
|
isInitialized = true;
|
|
6517
6637
|
resolve();
|
|
6518
6638
|
}).catch((error) => {
|
|
6519
|
-
console.error('Failed to authenticate with API key or fetch config for this app:', error);
|
|
6520
|
-
console.error('Please check your API key and try again.');
|
|
6521
6639
|
reject(new Error("Failed to initialize Tarobase app."));
|
|
6522
6640
|
});
|
|
6523
6641
|
});
|
|
@@ -6621,16 +6739,11 @@ async function get(path, opts = {}) {
|
|
|
6621
6739
|
// Helper to clean up expired cache entries
|
|
6622
6740
|
function cleanupExpiredCache() {
|
|
6623
6741
|
const now = Date.now();
|
|
6624
|
-
let removedCount = 0;
|
|
6625
6742
|
Object.keys(getCache).forEach(key => {
|
|
6626
6743
|
if (getCache[key] && getCache[key].expiresAt < now) {
|
|
6627
6744
|
delete getCache[key];
|
|
6628
|
-
removedCount++;
|
|
6629
6745
|
}
|
|
6630
6746
|
});
|
|
6631
|
-
if (removedCount > 0) {
|
|
6632
|
-
console.debug(`Cleaned up ${removedCount} expired cache entries`);
|
|
6633
|
-
}
|
|
6634
6747
|
lastCacheCleanup = now;
|
|
6635
6748
|
}
|
|
6636
6749
|
async function runQuery(absolutePath, queryName, queryArgs) {
|
|
@@ -6764,7 +6877,6 @@ async function setMany(many, options) {
|
|
|
6764
6877
|
}
|
|
6765
6878
|
}
|
|
6766
6879
|
catch (error) {
|
|
6767
|
-
console.error("Error setting data", error);
|
|
6768
6880
|
throw error;
|
|
6769
6881
|
}
|
|
6770
6882
|
async function handleSolanaTransaction(tx, authProvider, options) {
|
|
@@ -6881,9 +6993,7 @@ async function setFile(path, file) {
|
|
|
6881
6993
|
});
|
|
6882
6994
|
// 3) Check if the upload was successful
|
|
6883
6995
|
if (!uploadResponse.ok) {
|
|
6884
|
-
|
|
6885
|
-
const errorText = await uploadResponse.text();
|
|
6886
|
-
console.error('S3 Error Body:', errorText);
|
|
6996
|
+
await uploadResponse.text();
|
|
6887
6997
|
throw new Error(`Upload failed with status: ${uploadResponse.status}`);
|
|
6888
6998
|
}
|
|
6889
6999
|
// Optionally return the file's public URL or some confirmation
|
|
@@ -7571,10 +7681,9 @@ async function subscribe(path, subscriptionOptions) {
|
|
|
7571
7681
|
}
|
|
7572
7682
|
});
|
|
7573
7683
|
ws.addEventListener('error', (event) => {
|
|
7574
|
-
console.error(`WebSocket error for path: ${connectionKey}`, event);
|
|
7575
7684
|
notifyError(connectionKey, event);
|
|
7576
7685
|
});
|
|
7577
|
-
ws.addEventListener('close', (
|
|
7686
|
+
ws.addEventListener('close', () => {
|
|
7578
7687
|
// Connection will be recreated on next subscription if needed
|
|
7579
7688
|
});
|
|
7580
7689
|
return async () => await removeSubscription(connectionKey, subscriptionOptions);
|
|
@@ -7615,8 +7724,7 @@ async function removeSubscription(connectionKey, subscription) {
|
|
|
7615
7724
|
ws.addEventListener('close', () => {
|
|
7616
7725
|
resolve();
|
|
7617
7726
|
});
|
|
7618
|
-
ws.addEventListener('error', (
|
|
7619
|
-
console.error(`WebSocket closure error for connection: ${connectionKey}`, err);
|
|
7727
|
+
ws.addEventListener('error', () => {
|
|
7620
7728
|
resolve(); // Resolve even on error to avoid hanging
|
|
7621
7729
|
});
|
|
7622
7730
|
ws.close();
|
|
@@ -7631,6 +7739,7 @@ exports.buildSetDocumentsTransaction = buildSetDocumentsTransaction;
|
|
|
7631
7739
|
exports.convertRemainingAccounts = convertRemainingAccounts;
|
|
7632
7740
|
exports.createSessionWithPrivy = createSessionWithPrivy;
|
|
7633
7741
|
exports.createSessionWithSignature = createSessionWithSignature;
|
|
7742
|
+
exports.genAuthNonce = genAuthNonce;
|
|
7634
7743
|
exports.genSolanaMessage = genSolanaMessage;
|
|
7635
7744
|
exports.get = get;
|
|
7636
7745
|
exports.getConfig = getConfig;
|