@pooflabs/web 0.0.17 → 0.0.19
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/auth/index.d.ts +5 -4
- package/dist/auth/providers/offchain-auth-provider.d.ts +36 -0
- package/dist/index.d.ts +12 -11
- package/dist/index.esm.js +653 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +653 -20
- package/dist/index.js.map +1 -1
- package/package.json +58 -58
package/dist/index.esm.js
CHANGED
|
@@ -12453,8 +12453,9 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
12453
12453
|
const config = await getConfig();
|
|
12454
12454
|
async function executeRequest() {
|
|
12455
12455
|
const authHeader = await createAuthHeader(config.isServer);
|
|
12456
|
-
const headers = Object.assign({
|
|
12457
|
-
if (typeof window !==
|
|
12456
|
+
const headers = Object.assign({ "Content-Type": "application/json", "X-Public-App-Id": config.appId, "X-App-Id": config.appId }, authHeader);
|
|
12457
|
+
if (typeof window !== "undefined" &&
|
|
12458
|
+
window.CUSTOM_TAROBASE_APP_ID_HEADER) {
|
|
12458
12459
|
const customAppId = window.CUSTOM_TAROBASE_APP_ID_HEADER;
|
|
12459
12460
|
if (customAppId) {
|
|
12460
12461
|
headers["X-App-Id"] = customAppId;
|
|
@@ -12464,12 +12465,18 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
12464
12465
|
if (_overrides === null || _overrides === void 0 ? void 0 : _overrides.headers) {
|
|
12465
12466
|
Object.assign(headers, _overrides.headers);
|
|
12466
12467
|
}
|
|
12468
|
+
// Signal to backend that client supports offchain transaction signing
|
|
12469
|
+
if (typeof window !== "undefined" &&
|
|
12470
|
+
window.TAROBASE_SUPPORTS_OFFCHAIN_SIGNING) {
|
|
12471
|
+
console.log("X-Supports-Offchain-Signing", "true");
|
|
12472
|
+
headers["X-Supports-Offchain-Signing"] = "true";
|
|
12473
|
+
}
|
|
12467
12474
|
const requestConfig = {
|
|
12468
12475
|
method,
|
|
12469
|
-
url: `${config.apiUrl}${urlPath.startsWith(
|
|
12476
|
+
url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
|
|
12470
12477
|
headers,
|
|
12471
12478
|
};
|
|
12472
|
-
if (method !==
|
|
12479
|
+
if (method !== "GET" && method !== "get") {
|
|
12473
12480
|
requestConfig.data = data ? JSON.stringify(data) : {};
|
|
12474
12481
|
}
|
|
12475
12482
|
const response = await globalAxios(requestConfig);
|
|
@@ -12486,7 +12493,9 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
12486
12493
|
throw new Error("No refresh token found");
|
|
12487
12494
|
}
|
|
12488
12495
|
const refreshData = await refreshSession(refreshToken);
|
|
12489
|
-
if (refreshData &&
|
|
12496
|
+
if (refreshData &&
|
|
12497
|
+
refreshData.idToken &&
|
|
12498
|
+
refreshData.accessToken) {
|
|
12490
12499
|
updateIdTokenAndAccessToken(refreshData.idToken, refreshData.accessToken);
|
|
12491
12500
|
}
|
|
12492
12501
|
return await executeRequest();
|
|
@@ -12754,9 +12763,15 @@ async function setMany(many, options) {
|
|
|
12754
12763
|
clearCacheByPrefix(path);
|
|
12755
12764
|
});
|
|
12756
12765
|
if (setResponse.status === 202) {
|
|
12757
|
-
// This means that the document needs to be set on-chain
|
|
12758
|
-
// required info to run this transaction.
|
|
12759
|
-
const transactions = setResponse.data
|
|
12766
|
+
// This means that the document needs to be set on-chain (or signed for offchain),
|
|
12767
|
+
// the API did nothing and gave us the required info to run this transaction.
|
|
12768
|
+
const { transactions, offchainTransaction } = setResponse.data;
|
|
12769
|
+
// Handle offchain transaction flow (for 'offchain' protocol apps)
|
|
12770
|
+
if (offchainTransaction) {
|
|
12771
|
+
const transactionResult = await handleOffchainTransaction(offchainTransaction, authProvider, options);
|
|
12772
|
+
return Object.assign(Object.assign({}, documents.map(d => d.document)), { transactionId: transactionResult.signature, signedTransaction: transactionResult.signedTransaction });
|
|
12773
|
+
}
|
|
12774
|
+
// Handle Solana on-chain transaction flow
|
|
12760
12775
|
let lastTxSignature = undefined;
|
|
12761
12776
|
let signedTransaction = undefined;
|
|
12762
12777
|
for (let i = 0; i < transactions.length; i++) {
|
|
@@ -12837,6 +12852,40 @@ async function setMany(many, options) {
|
|
|
12837
12852
|
const transactionResult = await authProvider.runTransaction(undefined, solTransaction, options);
|
|
12838
12853
|
return transactionResult;
|
|
12839
12854
|
}
|
|
12855
|
+
async function handleOffchainTransaction(tx, authProvider, options) {
|
|
12856
|
+
const config = await getConfig();
|
|
12857
|
+
// 1. Sign the transaction message using the auth provider
|
|
12858
|
+
const signature = await authProvider.signMessage(tx.message);
|
|
12859
|
+
// 2. Create signed transaction
|
|
12860
|
+
const signedTx = {
|
|
12861
|
+
transaction: tx,
|
|
12862
|
+
signature
|
|
12863
|
+
};
|
|
12864
|
+
// 3. If shouldSubmitTx is false, return signed but not submitted
|
|
12865
|
+
if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
|
|
12866
|
+
return {
|
|
12867
|
+
signature: '',
|
|
12868
|
+
signedTransaction: bufferExports.Buffer.from(JSON.stringify(signedTx)).toString('base64')
|
|
12869
|
+
};
|
|
12870
|
+
}
|
|
12871
|
+
// 4. Submit to RPC endpoint
|
|
12872
|
+
const rpcUrl = `${config.apiUrl}/app/${config.appId}/rpc`;
|
|
12873
|
+
const rpcResponse = await fetch(rpcUrl, {
|
|
12874
|
+
method: 'POST',
|
|
12875
|
+
headers: { 'Content-Type': 'application/json' },
|
|
12876
|
+
body: JSON.stringify({
|
|
12877
|
+
jsonrpc: '2.0',
|
|
12878
|
+
id: 1,
|
|
12879
|
+
method: 'sendTransaction',
|
|
12880
|
+
params: [bufferExports.Buffer.from(JSON.stringify(signedTx)).toString('base64')]
|
|
12881
|
+
})
|
|
12882
|
+
});
|
|
12883
|
+
const result = await rpcResponse.json();
|
|
12884
|
+
if (result.error) {
|
|
12885
|
+
throw new Error(result.error.message);
|
|
12886
|
+
}
|
|
12887
|
+
return { signature: result.result };
|
|
12888
|
+
}
|
|
12840
12889
|
}
|
|
12841
12890
|
// Helper to clear cache entries by prefix
|
|
12842
12891
|
function clearCacheByPrefix(prefix) {
|
|
@@ -42713,6 +42762,584 @@ class MockAuthProvider {
|
|
|
42713
42762
|
}
|
|
42714
42763
|
}
|
|
42715
42764
|
|
|
42765
|
+
/**
|
|
42766
|
+
* OffchainAuthProvider wraps a real auth provider (e.g., Privy) to add
|
|
42767
|
+
* transaction signing via a custom modal for the poofnet environment.
|
|
42768
|
+
*
|
|
42769
|
+
* Instead of using wallet signing (which requires EVM/Solana compatibility),
|
|
42770
|
+
* this shows a custom confirmation modal and generates a mock signature.
|
|
42771
|
+
*/
|
|
42772
|
+
class OffchainAuthProvider {
|
|
42773
|
+
constructor(wrappedProvider, config = {}) {
|
|
42774
|
+
this.modalContainer = null;
|
|
42775
|
+
this.wrappedProvider = wrappedProvider;
|
|
42776
|
+
this.config = config;
|
|
42777
|
+
// Signal to API layer that this client supports offchain transaction signing
|
|
42778
|
+
if (typeof window !== "undefined") {
|
|
42779
|
+
console.log("TAROBASE_SUPPORTS_OFFCHAIN_SIGNING", "true");
|
|
42780
|
+
window.TAROBASE_SUPPORTS_OFFCHAIN_SIGNING = true;
|
|
42781
|
+
}
|
|
42782
|
+
}
|
|
42783
|
+
// ============ Delegated Methods ============
|
|
42784
|
+
async login() {
|
|
42785
|
+
const user = await this.wrappedProvider.login();
|
|
42786
|
+
if (user) {
|
|
42787
|
+
return Object.assign(Object.assign({}, user), { provider: this });
|
|
42788
|
+
}
|
|
42789
|
+
return null;
|
|
42790
|
+
}
|
|
42791
|
+
async logout() {
|
|
42792
|
+
await this.wrappedProvider.logout();
|
|
42793
|
+
}
|
|
42794
|
+
async restoreSession() {
|
|
42795
|
+
const user = await this.wrappedProvider.restoreSession();
|
|
42796
|
+
if (user) {
|
|
42797
|
+
return Object.assign(Object.assign({}, user), { provider: this });
|
|
42798
|
+
}
|
|
42799
|
+
return null;
|
|
42800
|
+
}
|
|
42801
|
+
async runTransaction(evmTransactionData, solTransactionData, options) {
|
|
42802
|
+
return this.wrappedProvider.runTransaction(evmTransactionData, solTransactionData, options);
|
|
42803
|
+
}
|
|
42804
|
+
async signTransaction(tx) {
|
|
42805
|
+
return this.wrappedProvider.signTransaction(tx);
|
|
42806
|
+
}
|
|
42807
|
+
async getNativeMethods() {
|
|
42808
|
+
return this.wrappedProvider.getNativeMethods();
|
|
42809
|
+
}
|
|
42810
|
+
// ============ Poofnet signMessage with Custom Modal ============
|
|
42811
|
+
async signMessage(message) {
|
|
42812
|
+
var _a, _b, _c, _d, _e, _f;
|
|
42813
|
+
// Callback: signing started
|
|
42814
|
+
(_b = (_a = this.config).onSigningStart) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
42815
|
+
try {
|
|
42816
|
+
// Show custom modal and wait for user confirmation
|
|
42817
|
+
const confirmed = await this.showTransactionModal(message);
|
|
42818
|
+
if (!confirmed) {
|
|
42819
|
+
throw new Error("Transaction rejected by user");
|
|
42820
|
+
}
|
|
42821
|
+
// Generate mock signature (hash of message)
|
|
42822
|
+
const signature = await this.generateMockSignature(message);
|
|
42823
|
+
// Callback: signing complete
|
|
42824
|
+
(_d = (_c = this.config).onSigningComplete) === null || _d === void 0 ? void 0 : _d.call(_c, signature);
|
|
42825
|
+
return signature;
|
|
42826
|
+
}
|
|
42827
|
+
catch (error) {
|
|
42828
|
+
// Callback: signing error
|
|
42829
|
+
(_f = (_e = this.config).onSigningError) === null || _f === void 0 ? void 0 : _f.call(_e, error);
|
|
42830
|
+
throw error;
|
|
42831
|
+
}
|
|
42832
|
+
}
|
|
42833
|
+
// ============ Modal Implementation ============
|
|
42834
|
+
async showTransactionModal(message) {
|
|
42835
|
+
return new Promise((resolve) => {
|
|
42836
|
+
// Parse the transaction message for display
|
|
42837
|
+
let parsed = {};
|
|
42838
|
+
try {
|
|
42839
|
+
parsed = JSON.parse(message);
|
|
42840
|
+
}
|
|
42841
|
+
catch (_a) {
|
|
42842
|
+
// If not JSON, just show raw message
|
|
42843
|
+
}
|
|
42844
|
+
// Create modal container
|
|
42845
|
+
this.modalContainer = document.createElement("div");
|
|
42846
|
+
this.modalContainer.id = "poofnet-tx-modal";
|
|
42847
|
+
this.modalContainer.innerHTML = this.getModalHTML(parsed, message);
|
|
42848
|
+
document.body.appendChild(this.modalContainer);
|
|
42849
|
+
// Add styles
|
|
42850
|
+
const style = document.createElement("style");
|
|
42851
|
+
style.textContent = this.getModalStyles();
|
|
42852
|
+
this.modalContainer.appendChild(style);
|
|
42853
|
+
// Animate in
|
|
42854
|
+
requestAnimationFrame(() => {
|
|
42855
|
+
var _a, _b;
|
|
42856
|
+
const overlay = (_a = this.modalContainer) === null || _a === void 0 ? void 0 : _a.querySelector(".poofnet-modal-overlay");
|
|
42857
|
+
const content = (_b = this.modalContainer) === null || _b === void 0 ? void 0 : _b.querySelector(".poofnet-modal-content");
|
|
42858
|
+
if (overlay)
|
|
42859
|
+
overlay.style.opacity = "1";
|
|
42860
|
+
if (content) {
|
|
42861
|
+
content.style.opacity = "1";
|
|
42862
|
+
content.style.transform = "translateY(0)";
|
|
42863
|
+
}
|
|
42864
|
+
});
|
|
42865
|
+
// Handle confirm
|
|
42866
|
+
const confirmBtn = this.modalContainer.querySelector("#poofnet-confirm-btn");
|
|
42867
|
+
confirmBtn === null || confirmBtn === void 0 ? void 0 : confirmBtn.addEventListener("click", () => {
|
|
42868
|
+
this.closeModal();
|
|
42869
|
+
resolve(true);
|
|
42870
|
+
});
|
|
42871
|
+
// Handle cancel
|
|
42872
|
+
const cancelBtn = this.modalContainer.querySelector("#poofnet-cancel-btn");
|
|
42873
|
+
cancelBtn === null || cancelBtn === void 0 ? void 0 : cancelBtn.addEventListener("click", () => {
|
|
42874
|
+
this.closeModal();
|
|
42875
|
+
resolve(false);
|
|
42876
|
+
});
|
|
42877
|
+
// Handle close button
|
|
42878
|
+
const closeBtn = this.modalContainer.querySelector("#poofnet-close-btn");
|
|
42879
|
+
closeBtn === null || closeBtn === void 0 ? void 0 : closeBtn.addEventListener("click", () => {
|
|
42880
|
+
this.closeModal();
|
|
42881
|
+
resolve(false);
|
|
42882
|
+
});
|
|
42883
|
+
// Handle overlay click
|
|
42884
|
+
const overlay = this.modalContainer.querySelector(".poofnet-modal-overlay");
|
|
42885
|
+
overlay === null || overlay === void 0 ? void 0 : overlay.addEventListener("click", (e) => {
|
|
42886
|
+
if (e.target === overlay) {
|
|
42887
|
+
this.closeModal();
|
|
42888
|
+
resolve(false);
|
|
42889
|
+
}
|
|
42890
|
+
});
|
|
42891
|
+
// Handle escape key
|
|
42892
|
+
const escHandler = (e) => {
|
|
42893
|
+
if (e.key === "Escape") {
|
|
42894
|
+
document.removeEventListener("keydown", escHandler);
|
|
42895
|
+
this.closeModal();
|
|
42896
|
+
resolve(false);
|
|
42897
|
+
}
|
|
42898
|
+
};
|
|
42899
|
+
document.addEventListener("keydown", escHandler);
|
|
42900
|
+
});
|
|
42901
|
+
}
|
|
42902
|
+
closeModal() {
|
|
42903
|
+
if (this.modalContainer) {
|
|
42904
|
+
const overlay = this.modalContainer.querySelector(".poofnet-modal-overlay");
|
|
42905
|
+
const content = this.modalContainer.querySelector(".poofnet-modal-content");
|
|
42906
|
+
if (overlay)
|
|
42907
|
+
overlay.style.opacity = "0";
|
|
42908
|
+
if (content) {
|
|
42909
|
+
content.style.opacity = "0";
|
|
42910
|
+
content.style.transform = "translateY(20px)";
|
|
42911
|
+
}
|
|
42912
|
+
setTimeout(() => {
|
|
42913
|
+
var _a;
|
|
42914
|
+
(_a = this.modalContainer) === null || _a === void 0 ? void 0 : _a.remove();
|
|
42915
|
+
this.modalContainer = null;
|
|
42916
|
+
}, 200);
|
|
42917
|
+
}
|
|
42918
|
+
}
|
|
42919
|
+
formatPath(path) {
|
|
42920
|
+
const parts = path.split("/").filter(Boolean);
|
|
42921
|
+
if (parts.length >= 2) {
|
|
42922
|
+
return {
|
|
42923
|
+
collection: parts[0],
|
|
42924
|
+
documentId: parts[parts.length - 1],
|
|
42925
|
+
};
|
|
42926
|
+
}
|
|
42927
|
+
return { collection: parts[0] || path, documentId: null };
|
|
42928
|
+
}
|
|
42929
|
+
formatFieldValue(value) {
|
|
42930
|
+
if (value === null || value === undefined)
|
|
42931
|
+
return "null";
|
|
42932
|
+
if (typeof value === "string") {
|
|
42933
|
+
return value.length > 30
|
|
42934
|
+
? `"${value.slice(0, 30)}..."`
|
|
42935
|
+
: `"${value}"`;
|
|
42936
|
+
}
|
|
42937
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
42938
|
+
return String(value);
|
|
42939
|
+
if (Array.isArray(value))
|
|
42940
|
+
return `[${value.length} items]`;
|
|
42941
|
+
if (typeof value === "object")
|
|
42942
|
+
return `{${Object.keys(value).length} fields}`;
|
|
42943
|
+
return String(value);
|
|
42944
|
+
}
|
|
42945
|
+
getActionDescription(type, collection, isNew) {
|
|
42946
|
+
if (type === "delete")
|
|
42947
|
+
return `Delete from ${collection}`;
|
|
42948
|
+
return isNew ? `Create in ${collection}` : `Update ${collection}`;
|
|
42949
|
+
}
|
|
42950
|
+
getModalHTML(parsed, rawMessage) {
|
|
42951
|
+
const instructions = parsed.instructions || [];
|
|
42952
|
+
// Group instructions by type for summary
|
|
42953
|
+
const sets = instructions.filter((i) => i.type === "set");
|
|
42954
|
+
const deletes = instructions.filter((i) => i.type === "delete");
|
|
42955
|
+
const instructionsList = instructions
|
|
42956
|
+
.map((inst) => {
|
|
42957
|
+
const { collection, documentId } = this.formatPath(inst.path);
|
|
42958
|
+
const isDelete = inst.type === "delete";
|
|
42959
|
+
const icon = isDelete ? "🗑️" : "✏️";
|
|
42960
|
+
const actionClass = isDelete
|
|
42961
|
+
? "poofnet-action-delete"
|
|
42962
|
+
: "poofnet-action-set";
|
|
42963
|
+
// Format data fields for display
|
|
42964
|
+
let fieldsHtml = "";
|
|
42965
|
+
if (inst.data && !isDelete) {
|
|
42966
|
+
const fields = Object.entries(inst.data)
|
|
42967
|
+
.filter(([key]) => !key.startsWith("_")) // Hide internal fields
|
|
42968
|
+
.slice(0, 4);
|
|
42969
|
+
if (fields.length > 0) {
|
|
42970
|
+
fieldsHtml = `
|
|
42971
|
+
<div class="poofnet-fields">
|
|
42972
|
+
${fields
|
|
42973
|
+
.map(([key, value]) => `
|
|
42974
|
+
<div class="poofnet-field">
|
|
42975
|
+
<span class="poofnet-field-key">${key}:</span>
|
|
42976
|
+
<span class="poofnet-field-value">${this.formatFieldValue(value)}</span>
|
|
42977
|
+
</div>
|
|
42978
|
+
`)
|
|
42979
|
+
.join("")}
|
|
42980
|
+
${Object.keys(inst.data).filter((k) => !k.startsWith("_"))
|
|
42981
|
+
.length > 4
|
|
42982
|
+
? `<div class="poofnet-field-more">+${Object.keys(inst.data).filter((k) => !k.startsWith("_")).length - 4} more fields</div>`
|
|
42983
|
+
: ""}
|
|
42984
|
+
</div>
|
|
42985
|
+
`;
|
|
42986
|
+
}
|
|
42987
|
+
}
|
|
42988
|
+
return `
|
|
42989
|
+
<div class="poofnet-instruction ${actionClass}">
|
|
42990
|
+
<div class="poofnet-instruction-header">
|
|
42991
|
+
<span class="poofnet-instruction-icon">${icon}</span>
|
|
42992
|
+
<span class="poofnet-instruction-action">${isDelete ? "Delete" : "Save"}</span>
|
|
42993
|
+
<span class="poofnet-instruction-collection">${collection}</span>
|
|
42994
|
+
</div>
|
|
42995
|
+
${documentId
|
|
42996
|
+
? `<div class="poofnet-instruction-id">ID: ${documentId}</div>`
|
|
42997
|
+
: ""}
|
|
42998
|
+
${fieldsHtml}
|
|
42999
|
+
</div>
|
|
43000
|
+
`;
|
|
43001
|
+
})
|
|
43002
|
+
.join("");
|
|
43003
|
+
// Create summary text
|
|
43004
|
+
let summaryText = "";
|
|
43005
|
+
if (sets.length > 0 && deletes.length > 0) {
|
|
43006
|
+
summaryText = `${sets.length} update${sets.length > 1 ? "s" : ""}, ${deletes.length} delete${deletes.length > 1 ? "s" : ""}`;
|
|
43007
|
+
}
|
|
43008
|
+
else if (sets.length > 0) {
|
|
43009
|
+
summaryText = `${sets.length} update${sets.length > 1 ? "s" : ""}`;
|
|
43010
|
+
}
|
|
43011
|
+
else if (deletes.length > 0) {
|
|
43012
|
+
summaryText = `${deletes.length} delete${deletes.length > 1 ? "s" : ""}`;
|
|
43013
|
+
}
|
|
43014
|
+
return `
|
|
43015
|
+
<div class="poofnet-modal-overlay">
|
|
43016
|
+
<div class="poofnet-modal-content">
|
|
43017
|
+
<button id="poofnet-close-btn" class="poofnet-close-btn" aria-label="Close">
|
|
43018
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
43019
|
+
<path d="M1 1L13 13M1 13L13 1" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
43020
|
+
</svg>
|
|
43021
|
+
</button>
|
|
43022
|
+
<div class="poofnet-modal-header">
|
|
43023
|
+
<div class="poofnet-modal-icon">🔐</div>
|
|
43024
|
+
<h2 class="poofnet-modal-title">Confirm Transaction</h2>
|
|
43025
|
+
<p class="poofnet-modal-subtitle">Poofnet Simulated Blockchain</p>
|
|
43026
|
+
</div>
|
|
43027
|
+
|
|
43028
|
+
<div class="poofnet-modal-body">
|
|
43029
|
+
${instructions.length > 0
|
|
43030
|
+
? `
|
|
43031
|
+
${summaryText
|
|
43032
|
+
? `<div class="poofnet-summary">${summaryText}</div>`
|
|
43033
|
+
: ""}
|
|
43034
|
+
<div class="poofnet-instructions-list">
|
|
43035
|
+
${instructionsList}
|
|
43036
|
+
</div>
|
|
43037
|
+
`
|
|
43038
|
+
: `
|
|
43039
|
+
<div class="poofnet-section">
|
|
43040
|
+
<h3 class="poofnet-section-title">Message</h3>
|
|
43041
|
+
<pre class="poofnet-raw-message">${rawMessage.slice(0, 200)}${rawMessage.length > 200 ? "..." : ""}</pre>
|
|
43042
|
+
</div>
|
|
43043
|
+
`}
|
|
43044
|
+
|
|
43045
|
+
<div class="poofnet-info-box">
|
|
43046
|
+
<span class="poofnet-info-icon">ℹ️</span>
|
|
43047
|
+
<span class="poofnet-info-text">This is a simulated transaction. No real fees will be charged.</span>
|
|
43048
|
+
</div>
|
|
43049
|
+
</div>
|
|
43050
|
+
|
|
43051
|
+
<div class="poofnet-modal-footer">
|
|
43052
|
+
<button id="poofnet-cancel-btn" class="poofnet-btn poofnet-btn-cancel">Cancel</button>
|
|
43053
|
+
<button id="poofnet-confirm-btn" class="poofnet-btn poofnet-btn-confirm">Confirm</button>
|
|
43054
|
+
</div>
|
|
43055
|
+
</div>
|
|
43056
|
+
</div>
|
|
43057
|
+
`;
|
|
43058
|
+
}
|
|
43059
|
+
getModalStyles() {
|
|
43060
|
+
return `
|
|
43061
|
+
.poofnet-modal-overlay {
|
|
43062
|
+
position: fixed;
|
|
43063
|
+
top: 0;
|
|
43064
|
+
left: 0;
|
|
43065
|
+
right: 0;
|
|
43066
|
+
bottom: 0;
|
|
43067
|
+
background: rgba(0, 0, 0, 0.5);
|
|
43068
|
+
display: flex;
|
|
43069
|
+
align-items: center;
|
|
43070
|
+
justify-content: center;
|
|
43071
|
+
z-index: 999999;
|
|
43072
|
+
opacity: 0;
|
|
43073
|
+
transition: opacity 0.2s ease;
|
|
43074
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
43075
|
+
}
|
|
43076
|
+
|
|
43077
|
+
.poofnet-modal-content {
|
|
43078
|
+
background: white;
|
|
43079
|
+
border-radius: 16px;
|
|
43080
|
+
width: 90%;
|
|
43081
|
+
max-width: 420px;
|
|
43082
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
43083
|
+
opacity: 0;
|
|
43084
|
+
transform: translateY(20px);
|
|
43085
|
+
transition: all 0.2s ease;
|
|
43086
|
+
max-height: 90vh;
|
|
43087
|
+
overflow: hidden;
|
|
43088
|
+
display: flex;
|
|
43089
|
+
flex-direction: column;
|
|
43090
|
+
position: relative;
|
|
43091
|
+
}
|
|
43092
|
+
|
|
43093
|
+
.poofnet-close-btn {
|
|
43094
|
+
position: absolute;
|
|
43095
|
+
top: 12px;
|
|
43096
|
+
right: 12px;
|
|
43097
|
+
width: 28px;
|
|
43098
|
+
height: 28px;
|
|
43099
|
+
border: none;
|
|
43100
|
+
background: #f3f4f6;
|
|
43101
|
+
border-radius: 8px;
|
|
43102
|
+
cursor: pointer;
|
|
43103
|
+
display: flex;
|
|
43104
|
+
align-items: center;
|
|
43105
|
+
justify-content: center;
|
|
43106
|
+
color: #6b7280;
|
|
43107
|
+
transition: all 0.15s ease;
|
|
43108
|
+
z-index: 1;
|
|
43109
|
+
}
|
|
43110
|
+
|
|
43111
|
+
.poofnet-close-btn:hover {
|
|
43112
|
+
background: #e5e7eb;
|
|
43113
|
+
color: #374151;
|
|
43114
|
+
}
|
|
43115
|
+
|
|
43116
|
+
.poofnet-modal-header {
|
|
43117
|
+
padding: 24px 24px 16px;
|
|
43118
|
+
text-align: center;
|
|
43119
|
+
border-bottom: 1px solid #f0f0f0;
|
|
43120
|
+
flex-shrink: 0;
|
|
43121
|
+
}
|
|
43122
|
+
|
|
43123
|
+
.poofnet-modal-icon {
|
|
43124
|
+
font-size: 40px;
|
|
43125
|
+
margin-bottom: 8px;
|
|
43126
|
+
}
|
|
43127
|
+
|
|
43128
|
+
.poofnet-modal-title {
|
|
43129
|
+
margin: 0;
|
|
43130
|
+
font-size: 18px;
|
|
43131
|
+
font-weight: 600;
|
|
43132
|
+
color: #1a1a1a;
|
|
43133
|
+
}
|
|
43134
|
+
|
|
43135
|
+
.poofnet-modal-subtitle {
|
|
43136
|
+
margin: 4px 0 0;
|
|
43137
|
+
font-size: 13px;
|
|
43138
|
+
color: #8b5cf6;
|
|
43139
|
+
font-weight: 500;
|
|
43140
|
+
}
|
|
43141
|
+
|
|
43142
|
+
.poofnet-modal-body {
|
|
43143
|
+
padding: 16px 20px;
|
|
43144
|
+
overflow-y: auto;
|
|
43145
|
+
flex: 1;
|
|
43146
|
+
}
|
|
43147
|
+
|
|
43148
|
+
.poofnet-summary {
|
|
43149
|
+
font-size: 13px;
|
|
43150
|
+
color: #6b7280;
|
|
43151
|
+
margin-bottom: 12px;
|
|
43152
|
+
text-align: center;
|
|
43153
|
+
}
|
|
43154
|
+
|
|
43155
|
+
.poofnet-section {
|
|
43156
|
+
margin-bottom: 16px;
|
|
43157
|
+
}
|
|
43158
|
+
|
|
43159
|
+
.poofnet-section-title {
|
|
43160
|
+
font-size: 12px;
|
|
43161
|
+
font-weight: 600;
|
|
43162
|
+
color: #666;
|
|
43163
|
+
text-transform: uppercase;
|
|
43164
|
+
letter-spacing: 0.5px;
|
|
43165
|
+
margin: 0 0 8px;
|
|
43166
|
+
}
|
|
43167
|
+
|
|
43168
|
+
.poofnet-instructions-list {
|
|
43169
|
+
display: flex;
|
|
43170
|
+
flex-direction: column;
|
|
43171
|
+
gap: 10px;
|
|
43172
|
+
}
|
|
43173
|
+
|
|
43174
|
+
.poofnet-instruction {
|
|
43175
|
+
background: #f9fafb;
|
|
43176
|
+
border-radius: 10px;
|
|
43177
|
+
padding: 12px;
|
|
43178
|
+
border-left: 3px solid #8b5cf6;
|
|
43179
|
+
}
|
|
43180
|
+
|
|
43181
|
+
.poofnet-instruction.poofnet-action-delete {
|
|
43182
|
+
border-left-color: #ef4444;
|
|
43183
|
+
}
|
|
43184
|
+
|
|
43185
|
+
.poofnet-instruction-header {
|
|
43186
|
+
display: flex;
|
|
43187
|
+
align-items: center;
|
|
43188
|
+
gap: 8px;
|
|
43189
|
+
margin-bottom: 4px;
|
|
43190
|
+
}
|
|
43191
|
+
|
|
43192
|
+
.poofnet-instruction-icon {
|
|
43193
|
+
font-size: 16px;
|
|
43194
|
+
flex-shrink: 0;
|
|
43195
|
+
}
|
|
43196
|
+
|
|
43197
|
+
.poofnet-instruction-action {
|
|
43198
|
+
font-size: 13px;
|
|
43199
|
+
font-weight: 600;
|
|
43200
|
+
color: #8b5cf6;
|
|
43201
|
+
}
|
|
43202
|
+
|
|
43203
|
+
.poofnet-action-delete .poofnet-instruction-action {
|
|
43204
|
+
color: #ef4444;
|
|
43205
|
+
}
|
|
43206
|
+
|
|
43207
|
+
.poofnet-instruction-collection {
|
|
43208
|
+
font-size: 13px;
|
|
43209
|
+
font-weight: 500;
|
|
43210
|
+
color: #374151;
|
|
43211
|
+
}
|
|
43212
|
+
|
|
43213
|
+
.poofnet-instruction-id {
|
|
43214
|
+
font-size: 11px;
|
|
43215
|
+
color: #9ca3af;
|
|
43216
|
+
font-family: monospace;
|
|
43217
|
+
margin-bottom: 8px;
|
|
43218
|
+
word-break: break-all;
|
|
43219
|
+
}
|
|
43220
|
+
|
|
43221
|
+
.poofnet-fields {
|
|
43222
|
+
background: white;
|
|
43223
|
+
border-radius: 6px;
|
|
43224
|
+
padding: 8px 10px;
|
|
43225
|
+
margin-top: 8px;
|
|
43226
|
+
}
|
|
43227
|
+
|
|
43228
|
+
.poofnet-field {
|
|
43229
|
+
display: flex;
|
|
43230
|
+
gap: 8px;
|
|
43231
|
+
padding: 4px 0;
|
|
43232
|
+
font-size: 12px;
|
|
43233
|
+
border-bottom: 1px solid #f3f4f6;
|
|
43234
|
+
}
|
|
43235
|
+
|
|
43236
|
+
.poofnet-field:last-child {
|
|
43237
|
+
border-bottom: none;
|
|
43238
|
+
}
|
|
43239
|
+
|
|
43240
|
+
.poofnet-field-key {
|
|
43241
|
+
color: #6b7280;
|
|
43242
|
+
font-weight: 500;
|
|
43243
|
+
flex-shrink: 0;
|
|
43244
|
+
}
|
|
43245
|
+
|
|
43246
|
+
.poofnet-field-value {
|
|
43247
|
+
color: #374151;
|
|
43248
|
+
word-break: break-all;
|
|
43249
|
+
}
|
|
43250
|
+
|
|
43251
|
+
.poofnet-field-more {
|
|
43252
|
+
font-size: 11px;
|
|
43253
|
+
color: #9ca3af;
|
|
43254
|
+
padding-top: 4px;
|
|
43255
|
+
font-style: italic;
|
|
43256
|
+
}
|
|
43257
|
+
|
|
43258
|
+
.poofnet-raw-message {
|
|
43259
|
+
background: #f9fafb;
|
|
43260
|
+
border-radius: 8px;
|
|
43261
|
+
padding: 12px;
|
|
43262
|
+
font-size: 11px;
|
|
43263
|
+
font-family: monospace;
|
|
43264
|
+
color: #4b5563;
|
|
43265
|
+
white-space: pre-wrap;
|
|
43266
|
+
word-break: break-all;
|
|
43267
|
+
margin: 0;
|
|
43268
|
+
max-height: 120px;
|
|
43269
|
+
overflow-y: auto;
|
|
43270
|
+
}
|
|
43271
|
+
|
|
43272
|
+
.poofnet-info-box {
|
|
43273
|
+
display: flex;
|
|
43274
|
+
align-items: center;
|
|
43275
|
+
gap: 8px;
|
|
43276
|
+
background: #faf5ff;
|
|
43277
|
+
border-radius: 8px;
|
|
43278
|
+
padding: 10px 12px;
|
|
43279
|
+
margin-top: 12px;
|
|
43280
|
+
}
|
|
43281
|
+
|
|
43282
|
+
.poofnet-info-icon {
|
|
43283
|
+
font-size: 14px;
|
|
43284
|
+
flex-shrink: 0;
|
|
43285
|
+
}
|
|
43286
|
+
|
|
43287
|
+
.poofnet-info-text {
|
|
43288
|
+
font-size: 11px;
|
|
43289
|
+
color: #7c3aed;
|
|
43290
|
+
line-height: 1.4;
|
|
43291
|
+
}
|
|
43292
|
+
|
|
43293
|
+
.poofnet-modal-footer {
|
|
43294
|
+
padding: 16px 20px 20px;
|
|
43295
|
+
display: flex;
|
|
43296
|
+
gap: 12px;
|
|
43297
|
+
flex-shrink: 0;
|
|
43298
|
+
border-top: 1px solid #f0f0f0;
|
|
43299
|
+
}
|
|
43300
|
+
|
|
43301
|
+
.poofnet-btn {
|
|
43302
|
+
flex: 1;
|
|
43303
|
+
padding: 12px 16px;
|
|
43304
|
+
border-radius: 10px;
|
|
43305
|
+
font-size: 14px;
|
|
43306
|
+
font-weight: 600;
|
|
43307
|
+
cursor: pointer;
|
|
43308
|
+
transition: all 0.15s ease;
|
|
43309
|
+
border: none;
|
|
43310
|
+
}
|
|
43311
|
+
|
|
43312
|
+
.poofnet-btn-cancel {
|
|
43313
|
+
background: #f3f4f6;
|
|
43314
|
+
color: #4b5563;
|
|
43315
|
+
}
|
|
43316
|
+
|
|
43317
|
+
.poofnet-btn-cancel:hover {
|
|
43318
|
+
background: #e5e7eb;
|
|
43319
|
+
}
|
|
43320
|
+
|
|
43321
|
+
.poofnet-btn-confirm {
|
|
43322
|
+
background: #8b5cf6;
|
|
43323
|
+
color: white;
|
|
43324
|
+
}
|
|
43325
|
+
|
|
43326
|
+
.poofnet-btn-confirm:hover {
|
|
43327
|
+
background: #7c3aed;
|
|
43328
|
+
}
|
|
43329
|
+
`;
|
|
43330
|
+
}
|
|
43331
|
+
async generateMockSignature(message) {
|
|
43332
|
+
// Generate a deterministic signature using SHA-256 hash of message
|
|
43333
|
+
// This can be verified on the backend by hashing the same message
|
|
43334
|
+
const encoder = new TextEncoder();
|
|
43335
|
+
const data = encoder.encode(message);
|
|
43336
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
43337
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
43338
|
+
const base64 = btoa(String.fromCharCode(...hashArray));
|
|
43339
|
+
return base64;
|
|
43340
|
+
}
|
|
43341
|
+
}
|
|
43342
|
+
|
|
42716
43343
|
let currentAuthProvider = null;
|
|
42717
43344
|
const SOLANA_DEVNET_RPC_URL = "https://idelle-8nxsep-fast-devnet.helius-rpc.com";
|
|
42718
43345
|
const SOLANA_MAINNET_RPC_URL = "https://celestia-cegncv-fast-mainnet.helius-rpc.com";
|
|
@@ -42723,41 +43350,46 @@ async function getAuthProvider(config) {
|
|
|
42723
43350
|
return currentAuthProvider;
|
|
42724
43351
|
}
|
|
42725
43352
|
if (!config) {
|
|
42726
|
-
throw new Error(
|
|
43353
|
+
throw new Error("Config is required to initialize auth provider");
|
|
42727
43354
|
}
|
|
42728
43355
|
// If mockAuth is enabled, use MockAuthProvider regardless of authMethod
|
|
42729
43356
|
if (config.mockAuth) {
|
|
42730
|
-
console.log(
|
|
43357
|
+
console.log("[MockAuth] Mock authentication enabled");
|
|
42731
43358
|
currentAuthProvider = new MockAuthProvider();
|
|
42732
43359
|
return currentAuthProvider;
|
|
42733
43360
|
}
|
|
42734
|
-
const authMethod = config.authMethod ||
|
|
43361
|
+
const authMethod = config.authMethod || "phantom";
|
|
42735
43362
|
const rpcUrl = (_a = config.rpcUrl) !== null && _a !== void 0 ? _a : null;
|
|
42736
43363
|
switch (authMethod) {
|
|
42737
|
-
case
|
|
42738
|
-
console.warn(
|
|
43364
|
+
case "wallet":
|
|
43365
|
+
console.warn("Wallet auth is not yet supported.");
|
|
42739
43366
|
break;
|
|
42740
|
-
case
|
|
43367
|
+
case "rainbowkit":
|
|
42741
43368
|
console.warn("Rainbow Kit auth is not yet supported.");
|
|
42742
43369
|
break;
|
|
42743
|
-
case
|
|
43370
|
+
case "privy":
|
|
42744
43371
|
currentAuthProvider = new PrivyWalletProvider((_b = config.name) !== null && _b !== void 0 ? _b : null, (_c = config.logoUrl) !== null && _c !== void 0 ? _c : null, config.privyConfig, rpcUrl);
|
|
42745
43372
|
break;
|
|
42746
|
-
case
|
|
43373
|
+
case "phantom":
|
|
42747
43374
|
currentAuthProvider = new PhantomWalletProvider(rpcUrl);
|
|
42748
43375
|
break;
|
|
42749
|
-
case
|
|
43376
|
+
case "onboard":
|
|
42750
43377
|
console.warn("Onboard auth is not yet supported.");
|
|
42751
43378
|
break;
|
|
42752
43379
|
}
|
|
42753
43380
|
if (!currentAuthProvider) {
|
|
42754
|
-
throw new Error(
|
|
43381
|
+
throw new Error("No auth provider was selected. Does your app have a supported auth method or chain configured?");
|
|
43382
|
+
}
|
|
43383
|
+
// Wrap with OffchainAuthProvider for offchain/poofnet chain
|
|
43384
|
+
if (config.chain === "offchain") {
|
|
43385
|
+
console.log("[Offchain] Wrapping auth provider for Poofnet transaction tracking");
|
|
43386
|
+
currentAuthProvider = new OffchainAuthProvider(currentAuthProvider);
|
|
42755
43387
|
}
|
|
42756
43388
|
return currentAuthProvider;
|
|
42757
43389
|
}
|
|
42758
43390
|
async function login$1() {
|
|
42759
43391
|
if (!currentAuthProvider) {
|
|
42760
|
-
throw new Error(
|
|
43392
|
+
throw new Error("Auth provider not initialized. Please call init() first.");
|
|
42761
43393
|
}
|
|
42762
43394
|
const loginResult = await currentAuthProvider.login();
|
|
42763
43395
|
if (loginResult) {
|
|
@@ -42767,7 +43399,7 @@ async function login$1() {
|
|
|
42767
43399
|
}
|
|
42768
43400
|
async function logout$1() {
|
|
42769
43401
|
if (!currentAuthProvider) {
|
|
42770
|
-
throw new Error(
|
|
43402
|
+
throw new Error("Auth provider not initialized. Please call init() first.");
|
|
42771
43403
|
}
|
|
42772
43404
|
await currentAuthProvider.logout();
|
|
42773
43405
|
}
|
|
@@ -42892,5 +43524,5 @@ async function getIdToken() {
|
|
|
42892
43524
|
return getIdToken$1(false);
|
|
42893
43525
|
}
|
|
42894
43526
|
|
|
42895
|
-
export { DEFAULT_TEST_ADDRESS, MockAuthProvider, PhantomWalletProvider, PrivyWalletProvider, ServerSessionManager, WebSessionManager, buildSetDocumentsTransaction, convertRemainingAccounts, createSessionWithPrivy, createSessionWithSignature, genAuthNonce, genSolanaMessage, get$2 as get, getAuthProvider, getConfig, getCurrentUser, getFiles, getIdToken, init, login, logout, onAuthStateChanged, refreshSession, runExpression, runExpressionMany, runQuery, runQueryMany, set$1 as set, setFile, setMany, signSessionCreateMessage, subscribe, useAuth };
|
|
43527
|
+
export { DEFAULT_TEST_ADDRESS, MockAuthProvider, OffchainAuthProvider, PhantomWalletProvider, PrivyWalletProvider, ServerSessionManager, WebSessionManager, buildSetDocumentsTransaction, convertRemainingAccounts, createSessionWithPrivy, createSessionWithSignature, genAuthNonce, genSolanaMessage, get$2 as get, getAuthProvider, getConfig, getCurrentUser, getFiles, getIdToken, init, login, logout, onAuthStateChanged, refreshSession, runExpression, runExpressionMany, runQuery, runQueryMany, set$1 as set, setFile, setMany, signSessionCreateMessage, subscribe, useAuth };
|
|
42896
43528
|
//# sourceMappingURL=index.esm.js.map
|