createSignInData.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { SolanaSignInInput } from "@solana/wallet-standard-features";
  2. export const createSignInData = async (): Promise<SolanaSignInInput> => {
  3. const now: Date = new Date();
  4. const uri = window.location.href
  5. const currentUrl = new URL(uri);
  6. const domain = currentUrl.host;
  7. // Convert the Date object to a string
  8. const currentDateTime = now.toISOString();
  9. const signInData: SolanaSignInInput = {
  10. domain,
  11. statement: "Clicking Sign or Approve only means you have proved this wallet is owned by you. This request will not trigger any blockchain transaction or cost any gas fee.",
  12. version: "1",
  13. nonce: "oBbLoEldZs",
  14. chainId: "mainnet",
  15. issuedAt: currentDateTime,
  16. resources: ["https://example.com", "https://phantom.app/"],
  17. };
  18. return signInData;
  19. };
  20. export const createSignInErrorData = async (): Promise<SolanaSignInInput> => {
  21. const now: Date = new Date();
  22. // Convert the Date object to a string
  23. const currentDateTime = now.toISOString();
  24. const signInData: SolanaSignInInput = {
  25. domain: "phishing.com",
  26. statement: "Sign-in to connect!",
  27. uri: "https://www.phishing.com",
  28. version: "1",
  29. nonce: "oBbLoEldZs",
  30. chainId: "solana:mainnet",
  31. issuedAt: currentDateTime,
  32. resources: ["https://example.com", "https://phantom.app/"]
  33. };
  34. return signInData;
  35. };