Edit: /tmp/tsx-0/17887-3c810d4a689641dda6c965c76341a853c1c87d67 (5185B)
{"code":"__filename=\"/opt/canhelp/node_modules/better-auth/node_modules/@better-auth/core/dist/social-providers/figma.mjs\";(()=>{\nvar __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,\"name\",{value,configurable:true});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from===\"object\"||typeof from===\"function\"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},\"__esModule\",{value:true}),mod);var figma_exports={};__export(figma_exports,{figma:()=>figma});module.exports=__toCommonJS(figma_exports);var import_logger=require(\"../env/logger.mjs\");var import_env=require(\"../env/index.mjs\");var import_error=require(\"../error/index.mjs\");var import_create_authorization_url=require(\"../oauth2/create-authorization-url.mjs\");var import_refresh_access_token=require(\"../oauth2/refresh-access-token.mjs\");var import_validate_authorization_code=require(\"../oauth2/validate-authorization-code.mjs\");var import_oauth2=require(\"../oauth2/index.mjs\");var import_fetch=require(\"@better-fetch/fetch\");const figma=__name(options=>{const tokenEndpoint=\"https://api.figma.com/v1/oauth/token\";return{id:\"figma\",name:\"Figma\",async createAuthorizationURL({state,scopes,codeVerifier,redirectURI}){if(!options.clientId||!options.clientSecret){import_logger.logger.error(\"Client Id and Client Secret are required for Figma. Make sure to provide them in the options.\");throw new import_error.BetterAuthError(\"CLIENT_ID_AND_SECRET_REQUIRED\")}if(!codeVerifier)throw new import_error.BetterAuthError(\"codeVerifier is required for Figma\");const _scopes=options.disableDefaultScope?[]:[\"current_user:read\"];if(options.scope)_scopes.push(...options.scope);if(scopes)_scopes.push(...scopes);return await(0,import_create_authorization_url.createAuthorizationURL)({id:\"figma\",options,authorizationEndpoint:\"https://www.figma.com/oauth\",scopes:_scopes,state,codeVerifier,redirectURI})},validateAuthorizationCode:__name(async({code,codeVerifier,redirectURI})=>{return(0,import_validate_authorization_code.validateAuthorizationCode)({code,codeVerifier,redirectURI,options,tokenEndpoint,authentication:\"basic\"})},\"validateAuthorizationCode\"),refreshAccessToken:options.refreshAccessToken?options.refreshAccessToken:async refreshToken=>{return(0,import_refresh_access_token.refreshAccessToken)({refreshToken,options:{clientId:options.clientId,clientKey:options.clientKey,clientSecret:options.clientSecret},tokenEndpoint,authentication:\"basic\"})},async getUserInfo(token){if(options.getUserInfo)return options.getUserInfo(token);try{const{data:profile}=await(0,import_fetch.betterFetch)(\"https://api.figma.com/v1/me\",{headers:{Authorization:`Bearer ${token.accessToken}`}});if(!profile){import_logger.logger.error(\"Failed to fetch user from Figma\");return null}const userMap=await options.mapProfileToUser?.(profile);return{user:{id:profile.id,name:profile.handle,email:profile.email,image:profile.img_url,emailVerified:false,...userMap},data:profile}}catch(error){import_logger.logger.error(\"Failed to fetch user info from Figma:\",error);return null}},options}},\"figma\");0&&(module.exports={figma});\n})()\n","warnings":[],"map":{"version":3,"mappings":";suBAAA,4HAAuB,6BACvB,eAAO,4BACP,iBAAgC,8BAChC,oCAAuC,kDACvC,gCAAmC,8CACnC,uCAA0C,qDAC1C,kBAAO,+BACP,iBAA4B,+BAG5B,MAAM,MAAQ,OAAC,SAAY,CAC1B,MAAM,cAAgB,uCACtB,MAAO,CACN,GAAI,QACJ,KAAM,QACN,MAAM,uBAAuB,CAAE,MAAO,OAAQ,aAAc,WAAY,EAAG,CAC1E,GAAI,CAAC,QAAQ,UAAY,CAAC,QAAQ,aAAc,CAC/C,qBAAO,MAAM,+FAA+F,EAC5G,MAAM,IAAI,6BAAgB,+BAA+B,CAC1D,CACA,GAAI,CAAC,aAAc,MAAM,IAAI,6BAAgB,oCAAoC,EACjF,MAAM,QAAU,QAAQ,oBAAsB,CAAC,EAAI,CAAC,mBAAmB,EACvE,GAAI,QAAQ,MAAO,QAAQ,KAAK,GAAG,QAAQ,KAAK,EAChD,GAAI,OAAQ,QAAQ,KAAK,GAAG,MAAM,EAClC,OAAO,QAAM,wDAAuB,CACnC,GAAI,QACJ,QACA,sBAAuB,8BACvB,OAAQ,QACR,MACA,aACA,WACD,CAAC,CACF,EACA,0BAA2B,aAAO,CAAE,KAAM,aAAc,WAAY,IAAM,CACzE,SAAO,8DAA0B,CAChC,KACA,aACA,YACA,QACA,cACA,eAAgB,OACjB,CAAC,CACF,EAT2B,6BAU3B,mBAAoB,QAAQ,mBAAqB,QAAQ,mBAAqB,MAAO,cAAiB,CACrG,SAAO,gDAAmB,CACzB,aACA,QAAS,CACR,SAAU,QAAQ,SAClB,UAAW,QAAQ,UACnB,aAAc,QAAQ,YACvB,EACA,cACA,eAAgB,OACjB,CAAC,CACF,EACA,MAAM,YAAY,MAAO,CACxB,GAAI,QAAQ,YAAa,OAAO,QAAQ,YAAY,KAAK,EACzD,GAAI,CACH,KAAM,CAAE,KAAM,OAAQ,EAAI,QAAM,0BAAY,8BAA+B,CAAE,QAAS,CAAE,cAAe,UAAU,MAAM,WAAW,EAAG,CAAE,CAAC,EACxI,GAAI,CAAC,QAAS,CACb,qBAAO,MAAM,iCAAiC,EAC9C,OAAO,IACR,CACA,MAAM,QAAU,MAAM,QAAQ,mBAAmB,OAAO,EACxD,MAAO,CACN,KAAM,CACL,GAAI,QAAQ,GACZ,KAAM,QAAQ,OACd,MAAO,QAAQ,MACf,MAAO,QAAQ,QACf,cAAe,MACf,GAAG,OACJ,EACA,KAAM,OACP,CACD,OAAS,MAAO,CACf,qBAAO,MAAM,wCAAyC,KAAK,EAC3D,OAAO,IACR,CACD,EACA,OACD,CACD,EAzEc","names":[],"ignoreList":[],"sources":["/opt/canhelp/node_modules/better-auth/node_modules/@better-auth/core/dist/social-providers/figma.mjs"],"sourcesContent":[null]}}