UNPKG

@coursebuilder/core

Version:

Core package for Course Builder

1 lines 2.54 kB
{"version":3,"sources":["../../src/providers/egghead.ts"],"sourcesContent":["import { OAuthConfig, OAuthUserConfig } from '@auth/core/providers'\n\nexport interface EggheadProfile extends Record<string, any> {\n\tid: string\n\tname: string\n\temail: string\n\tavatar_url: string\n\tinstructor_id?: number\n\troles: string[]\n\tinstructor?: {\n\t\tid: number\n\t\tfirst_name: string\n\t\tlast_name: string\n\t\tavatar_url: string\n\t\temail: string\n\t\tslug: string\n\t}\n}\n\nexport default function egghead(\n\tconfig: OAuthUserConfig<EggheadProfile>,\n): OAuthConfig<EggheadProfile> {\n\treturn {\n\t\tid: 'egghead',\n\t\tname: 'egghead',\n\t\ttype: 'oauth',\n\t\ttoken: 'https://app.egghead.io/oauth/token',\n\t\tauthorization: {\n\t\t\turl: 'https://app.egghead.io/oauth/authorize?response_type=code',\n\t\t\tparams: { scope: '' },\n\t\t},\n\t\tuserinfo: {\n\t\t\turl: 'https://app.egghead.io/api/v1/users/current',\n\t\t\tasync request({ tokens, provider }: any) {\n\t\t\t\tconst profile = await fetch(provider.userinfo?.url as URL, {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${tokens.access_token}`,\n\t\t\t\t\t\t'User-Agent': 'authjs',\n\t\t\t\t\t},\n\t\t\t\t}).then(async (res) => await res.json())\n\t\t\t\treturn profile\n\t\t\t},\n\t\t},\n\t\tprofile(profile: EggheadProfile) {\n\t\t\treturn {\n\t\t\t\tid: profile.id,\n\t\t\t\tname: profile.name,\n\t\t\t\temail: profile.email,\n\t\t\t\timage: profile.avatar_url,\n\t\t\t}\n\t\t},\n\t\tclientId: config.clientId,\n\t\tclientSecret: config.clientSecret,\n\t\tallowDangerousEmailAccountLinking: config.allowDangerousEmailAccountLinking,\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmBA;;;;;AAAe,SAAf,QACCA,QAAuC;AAEvC,SAAO;IACNC,IAAI;IACJC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPC,eAAe;MACdC,KAAK;MACLC,QAAQ;QAAEC,OAAO;MAAG;IACrB;IACAC,UAAU;MACTH,KAAK;MACL,MAAMI,QAAQ,EAAEC,QAAQC,SAAQ,GAAO;AACtC,cAAMC,UAAU,MAAMC,MAAMF,SAASH,UAAUH,KAAY;UAC1DS,SAAS;YACRC,eAAe,UAAUL,OAAOM,YAAY;YAC5C,cAAc;UACf;QACD,CAAA,EAAGC,KAAK,OAAOC,QAAQ,MAAMA,IAAIC,KAAI,CAAA;AACrC,eAAOP;MACR;IACD;IACAA,QAAQA,SAAuB;AAC9B,aAAO;QACNZ,IAAIY,QAAQZ;QACZC,MAAMW,QAAQX;QACdmB,OAAOR,QAAQQ;QACfC,OAAOT,QAAQU;MAChB;IACD;IACAC,UAAUxB,OAAOwB;IACjBC,cAAczB,OAAOyB;IACrBC,mCAAmC1B,OAAO0B;EAC3C;AACD;AApCwBC;","names":["config","id","name","type","token","authorization","url","params","scope","userinfo","request","tokens","provider","profile","fetch","headers","Authorization","access_token","then","res","json","email","image","avatar_url","clientId","clientSecret","allowDangerousEmailAccountLinking","egghead"]}