UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.45 kB
{"version":3,"file":"default-user-info-mapper.mjs","names":[],"sources":["../../../../src/libs/auth-providers/helpers/default-user-info-mapper.ts"],"sourcesContent":["import type { OIDCUserInfo, ServiceResponse } from \"../../../types.js\";\nimport { copy } from \"../../i18n/index.js\";\n\n/**\n * Maps a standard user info response to data we expect\n */\nconst mapStandardUserInfo = (\n\trawUserInfo: Record<string, unknown>,\n): Awaited<ServiceResponse<OIDCUserInfo>> => {\n\tconst userId = (rawUserInfo?.sub || rawUserInfo?.id) as string;\n\tconst firstName = (rawUserInfo?.given_name || rawUserInfo?.first_name) as\n\t\t| string\n\t\t| undefined;\n\tconst lastName = (rawUserInfo?.family_name || rawUserInfo?.last_name) as\n\t\t| string\n\t\t| undefined;\n\n\tif (!userId) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\tstatus: 400,\n\t\t\t\tname: copy(\"server:core.auth.oidc.user.info.incomplete.name\"),\n\t\t\t\tmessage: copy(\"server:core.auth.oidc.user.info.incomplete.message\"),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: { userId, firstName, lastName },\n\t};\n};\n\nexport default mapStandardUserInfo;\n"],"mappings":"2CAMA,MAAM,EACL,GAC4C,CAC5C,IAAM,EAAU,GAAa,KAAO,GAAa,GAC3C,EAAa,GAAa,YAAc,GAAa,WAGrD,EAAY,GAAa,aAAe,GAAa,UAe3D,OAXK,EAWE,CACN,MAAO,IAAA,GACP,KAAM,CAAE,SAAQ,YAAW,UAAS,CACrC,EAbQ,CACN,MAAO,CACN,OAAQ,IACR,KAAM,EAAK,iDAAiD,EAC5D,QAAS,EAAK,oDAAoD,CACnE,EACA,KAAM,IAAA,EACP,CAOF"}