Skip to content

Commit

Permalink
Merge d098192 into 7e8c84e
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehenry committed Oct 14, 2019
2 parents 7e8c84e + d098192 commit 9e22730
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/solid-auth-client.js
Expand Up @@ -15,6 +15,9 @@ const globalFetch = fetch

export type loginOptions = {
callbackUri: string,
clientName?: string,
contacts?: Array<string>,
logoUri?: string,
popupUri: string,
storage: AsyncStorage
}
Expand Down
27 changes: 22 additions & 5 deletions src/webid-oidc.js
Expand Up @@ -125,18 +125,34 @@ async function storeRp(
return rp
}

function registerRp(
idp: string,
{ storage, callbackUri }: loginOptions
): Promise<RelyingParty> {
function registerRp(idp: string, opts: loginOptions): Promise<RelyingParty> {
const { storage, callbackUri } = opts
const responseType = 'id_token token'

const clientNameI18n = {}
Object.entries(opts)
.filter(([key, _]) => key.startsWith('clientName#'))
.forEach(
([key, value]) =>
(clientNameI18n[key.replace('clientName#', 'client_name#')] = value)
)

const supplementaryOptions = {
logo_uri: opts.logoUri,
contacts: opts.contacts,
client_name: opts.clientName
}

const registration = {
issuer: idp,
grant_types: ['implicit'],
redirect_uris: [callbackUri],
response_types: [responseType],
scope: 'openid profile'
scope: 'openid profile',
...clientNameI18n,
...supplementaryOptions
}

const options = {
defaults: {
authenticate: {
Expand All @@ -146,6 +162,7 @@ function registerRp(
},
store: storage
}

return RelyingParty.register(idp, registration, options)
}

Expand Down

0 comments on commit 9e22730

Please sign in to comment.