Edit: /tmp/tsx-0/17887-8bf9a77a135ff639293a9efedcbb19b44b728888 (6080B)
{"code":"__filename=\"/opt/canhelp/node_modules/better-auth/dist/plugins/device-authorization/index.mjs\";(()=>{\nvar __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf;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 __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,\"default\",{value:mod,enumerable:true}):target,mod));var __toCommonJS=mod=>__copyProps(__defProp({},\"__esModule\",{value:true}),mod);var device_authorization_exports={};__export(device_authorization_exports,{deviceAuthorization:()=>deviceAuthorization,deviceAuthorizationOptionsSchema:()=>deviceAuthorizationOptionsSchema});module.exports=__toCommonJS(device_authorization_exports);var import_schema=require(\"../../db/schema.mjs\");var import_db=require(\"../../db/index.mjs\");var import_time=require(\"../../utils/time.mjs\");var import_error_codes=require(\"./error-codes.mjs\");var import_routes=require(\"./routes.mjs\");var import_schema2=require(\"./schema.mjs\");var z=__toESM(require(\"zod\"));const timeStringSchema=z.custom(val=>{if(typeof val!==\"string\")return false;try{(0,import_time.ms)(val);return true}catch{return false}},{message:\"Invalid time string format. Use formats like '30m', '5s', '1h', etc.\"});const deviceAuthorizationOptionsSchema=z.object({expiresIn:timeStringSchema.default(\"30m\").describe(\"Time in seconds until the device code expires. Use formats like '30m', '5s', '1h', etc.\"),interval:timeStringSchema.default(\"5s\").describe(\"Time in seconds between polling attempts. Use formats like '30m', '5s', '1h', etc.\"),deviceCodeLength:z.number().int().positive().default(40).describe(\"Length of the device code to be generated. Default is 40 characters.\"),userCodeLength:z.number().int().positive().default(8).describe(\"Length of the user code to be generated. Default is 8 characters.\"),generateDeviceCode:z.custom(val=>typeof val===\"function\",{message:\"generateDeviceCode must be a function that returns a string or a promise that resolves to a string.\"}).optional().describe(\"Function to generate a device code. If not provided, a default random string generator will be used.\"),generateUserCode:z.custom(val=>typeof val===\"function\",{message:\"generateUserCode must be a function that returns a string or a promise that resolves to a string.\"}).optional().describe(\"Function to generate a user code. If not provided, a default random string generator will be used.\"),validateClient:z.custom(val=>typeof val===\"function\",{message:\"validateClient must be a function that returns a boolean or a promise that resolves to a boolean.\"}).optional().describe(\"Function to validate the client ID. If not provided, no validation will be performed.\"),onDeviceAuthRequest:z.custom(val=>typeof val===\"function\",{message:\"onDeviceAuthRequest must be a function that returns void or a promise that resolves to void.\"}).optional().describe(\"Function to handle device authorization requests. If not provided, no additional actions will be taken.\"),verificationUri:z.string().optional().describe(\"The URI where users verify their device code. Can be an absolute URL (https://example.com/device) or relative path (/custom-path). This will be returned as verification_uri in the device code response. If not provided, defaults to /device.\"),schema:z.custom(()=>true)});const deviceAuthorization=__name((options={})=>{const opts=deviceAuthorizationOptionsSchema.parse(options);return{id:\"device-authorization\",schema:(0,import_schema.mergeSchema)(import_schema2.schema,options?.schema),endpoints:{deviceCode:(0,import_routes.deviceCode)(opts),deviceToken:(0,import_routes.deviceToken)(opts),deviceVerify:import_routes.deviceVerify,deviceApprove:import_routes.deviceApprove,deviceDeny:import_routes.deviceDeny},$ERROR_CODES:import_error_codes.DEVICE_AUTHORIZATION_ERROR_CODES,options}},\"deviceAuthorization\");0&&(module.exports={deviceAuthorization,deviceAuthorizationOptionsSchema});\n})()\n","warnings":[],"map":{"version":3,"mappings":";i/BAAA,2QAA4B,+BAC5B,cAAO,8BACP,gBAAmB,g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