{
  "version": 3,
  "sources": ["../../src/services/nativeAuth/nativeAuth.ts"],
  "sourcesContent": ["import { NativeAuthClient } from '@multiversx/sdk-native-auth-client';\n\nimport {\n  getLatestBlockHash,\n  LatestBlockHashType\n} from './helpers/getLatestBlockHash';\n\nimport { buildNativeAuthConfig } from './methods/buildNativeAuthConfig';\nimport { getTokenExpiration } from './methods/getTokenExpiration';\nimport { NativeAuthConfigType } from './nativeAuth.types';\n\ninterface NativeAuthInitType {\n  extraInfo?: { [key: string]: string };\n  latestBlockInfo?: LatestBlockHashType;\n  noCache?: boolean;\n}\n\nexport const nativeAuth = (config?: NativeAuthConfigType) => {\n  const {\n    origin,\n    apiAddress,\n    expirySeconds,\n    blockHashShard,\n    extraInfo: extraInfoFromConfig,\n    gatewayUrl,\n    extraRequestHeaders\n  } = buildNativeAuthConfig(config);\n\n  const nativeAuthClient = new NativeAuthClient({\n    origin,\n    apiUrl: apiAddress,\n    expirySeconds,\n    blockHashShard,\n    gatewayUrl,\n    extraRequestHeaders\n  });\n\n  const initialize = async (\n    initProps?: NativeAuthInitType\n  ): Promise<string> => {\n    if (!apiAddress || !origin) {\n      return '';\n    }\n\n    const getBlockHash = (): Promise<string> =>\n      nativeAuthClient.getCurrentBlockHash();\n\n    let latestBlockInfo = initProps?.latestBlockInfo;\n\n    latestBlockInfo ??= await getLatestBlockHash({\n      apiAddress,\n      blockHashShard,\n      getBlockHash,\n      noCache: initProps?.noCache\n    });\n\n    const { hash, timestamp } = latestBlockInfo;\n    const encodedExtraInfo = nativeAuthClient.encodeValue(\n      JSON.stringify({\n        ...(initProps?.extraInfo ?? extraInfoFromConfig),\n        ...(timestamp ? { timestamp } : {})\n      })\n    );\n    const encodedOrigin = nativeAuthClient.encodeValue(origin);\n\n    return `${encodedOrigin}.${hash}.${expirySeconds}.${encodedExtraInfo}`;\n  };\n\n  const getToken = ({\n    address,\n    token,\n    signature\n  }: {\n    address: string;\n    token: string;\n    signature: string;\n  }): string => nativeAuthClient.getToken(address, token, signature);\n\n  return {\n    initialize,\n    getToken,\n    getTokenExpiration\n  };\n};\n"],
  "mappings": "2HAAA,OAAS,oBAAAA,MAAwB,qCAiB1B,IAAMC,EAAcC,GAAkC,CAC3D,GAAM,CACJ,OAAAC,EACA,WAAAC,EACA,cAAAC,EACA,eAAAC,EACA,UAAWC,EACX,WAAAC,EACA,oBAAAC,CACF,EAAIC,EAAsBR,CAAM,EAE1BS,EAAmB,IAAIC,EAAiB,CAC5C,OAAAT,EACA,OAAQC,EACR,cAAAC,EACA,eAAAC,EACA,WAAAE,EACA,oBAAAC,CACF,CAAC,EA2CD,MAAO,CACL,WA1CiB,MACjBI,GACoB,CACpB,GAAI,CAACT,GAAc,CAACD,EAClB,MAAO,GAGT,IAAMW,EAAe,IACnBH,EAAiB,oBAAoB,EAEnCI,EAAkBF,GAAW,gBAEjCE,IAAoB,MAAMC,EAAmB,CAC3C,WAAAZ,EACA,eAAAE,EACA,aAAAQ,EACA,QAASD,GAAW,OACtB,CAAC,EAED,GAAM,CAAE,KAAAI,EAAM,UAAAC,CAAU,EAAIH,EACtBI,EAAmBR,EAAiB,YACxC,KAAK,UAAU,CACb,GAAIE,GAAW,WAAaN,EAC5B,GAAIW,EAAY,CAAE,UAAAA,CAAU,EAAI,CAAC,CACnC,CAAC,CACH,EAGA,MAAO,GAFeP,EAAiB,YAAYR,CAAM,CAElC,IAAIc,CAAI,IAAIZ,CAAa,IAAIc,CAAgB,EACtE,EAcE,SAZe,CAAC,CAChB,QAAAC,EACA,MAAAC,EACA,UAAAC,CACF,IAIcX,EAAiB,SAASS,EAASC,EAAOC,CAAS,EAK/D,mBAAAC,CACF,CACF",
  "names": ["NativeAuthClient", "nativeAuth", "config", "origin", "apiAddress", "expirySeconds", "blockHashShard", "extraInfoFromConfig", "gatewayUrl", "extraRequestHeaders", "buildNativeAuthConfig", "nativeAuthClient", "NativeAuthClient", "initProps", "getBlockHash", "latestBlockInfo", "getLatestBlockHash", "hash", "timestamp", "encodedExtraInfo", "address", "token", "signature", "getTokenExpiration"]
}
