Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{
"presets": ["flow", "react", "es2015"],
"presets": [
["flow"],
["react"],
["env", {
"targets": {
"browsers": ["last 2 versions"],
"node": "8",
}
}]
],
"plugins": [
"transform-runtime",
"transform-object-rest-spread",
"transform-class-properties",
"transform-async-to-generator"
]
}
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ language: node_js
node_js:
- node
script:
- yarn test
- npm test
after_success:
- yarn coverage:report
cache: yarn
- npm run coverage:report
cache:
directories:
- node_modules
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,18 @@ call `popupLogin({ popupUri: 'https://localhost:8080/popup.html' })`.

### Prerequisites

This library assumes you have [node](https://nodejs.org/en/) >= v7.10.1 and
[yarn](https://yarnpkg.com/) 0.24.6 installed. It may work with earlier
This library assumes you have [node](https://nodejs.org/en/) >= v7.10.1
installed. It may work with earlier
versions, but that hasn't been tested thus far.

### Setting up the development environment

```sh
$ git clone https://github.com/solid/solid-auth-client.git
$ cd solid-auth-client
$ yarn
$ yarn build # build the library and UMD bundle
$ yarn test # run the code formatter, linter, and test suite
$ yarn test:dev # just run the tests in watch mode
$ npm install
$ npm run test # run the code formatter, linter, and test suite
$ npm run test:dev # just run the tests in watch mode
```

### Acceptance Testing
Expand All @@ -185,11 +184,11 @@ You can test how `solid-auth-client` operates within an app by running the demo
#### Running the demo development server

```sh
$ POPUP_URI='http://localhost:8081/popup.html' yarn start:demo
$ POPUP_URI='http://localhost:8081/popup.html' npm run start:demo
```

#### Running the popup development server

```sh
$ APP_NAME='solid-auth-client demo' yarn start:popup
$ APP_NAME='solid-auth-client demo' npm run start:popup
```
8 changes: 4 additions & 4 deletions demo/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import Nav from './Nav'
import PersonalInfo from './PersonalInfo'
import Footer from './Footer'

import type { session } from '../../src/session'
import type { Session } from '../../src/session'
import { popupLogin, logout, currentSession } from '../../src/'

export default class App extends React.Component {
state: { session: ?session } = { session: null }
export default class App extends React.Component<Object, Object> {
state: { session: ?Session } = { session: null }

saveCredentials = (session: session): void => {
saveCredentials = (session: Session): void => {
this.setState({ session })
}

Expand Down
8 changes: 3 additions & 5 deletions demo/components/Copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import React from 'react'
const Copy = ({ loggedIn }: { loggedIn: boolean }) => (
<div className="mt-2">
This is a simple demo of the Solid Auth Client. You're currently
{loggedIn ? (
' logged in'
) : (
' anonymous. Click "Log in" to authenticate and see some information about yourself'
)}.
{loggedIn
? ' logged in'
: ' anonymous. Click "Log in" to authenticate and see some information about yourself'}.
</div>
)

Expand Down
16 changes: 8 additions & 8 deletions demo/components/PersonalInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import 'isomorphic-fetch'
import React from 'react'

import { fetch } from '../../src/'
import type { session } from '../../src/session'
import type { Session } from '../../src/session'

type profile = {
type Profile = {
'foaf:name': ?{ '@value': string }
}

export default class PersonalInfo extends React.Component {
props: { session: ?session }
export default class PersonalInfo extends React.Component<Object, Object> {
props: { session: ?Session }

defaultProps = {
session: null
}

state: { profile: profile } = {
state: { profile: Profile } = {
profile: { 'foaf:name': null }
}

fetchProfile = (webId: string): Promise<profile> => {
fetchProfile = (webId: string): Promise<Profile> => {
const query = `
@prefix foaf http://xmlns.com/foaf/0.1/
${webId} { foaf:name }
Expand All @@ -31,9 +31,9 @@ export default class PersonalInfo extends React.Component {
}).then(resp => resp.json())
}

saveProfile = (profile: profile): void => this.setState({ profile })
saveProfile = (profile: Profile): void => this.setState({ profile })

componentWillReceiveProps(props: { session: ?session }) {
componentWillReceiveProps(props: { session: ?Session }) {
if (props.session) {
this.fetchProfile(props.session.webId).then(this.saveProfile)
}
Expand Down
6 changes: 3 additions & 3 deletions demo/components/TextForm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import React from 'react'

export default class TextForm extends React.Component {
export default class TextForm extends React.Component<Object, Object> {
props: {
label: string,
placeholder: string,
Expand All @@ -13,8 +13,8 @@ export default class TextForm extends React.Component {
input: ''
}

updateInput = (event: Event & { target: EventTarget }) =>
this.setState({ input: event.target.value })
updateInput = (event: SyntheticEvent<HTMLInputElement>) =>
this.setState({ input: event.currentTarget.value })

handle = (handler: (input: string) => any) => (event: Event) => {
event.preventDefault()
Expand Down
6 changes: 6 additions & 0 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import App from './components/App'

import * as SolidAuthClient from '../src'

declare var module: {
hot: {
accept(path: string, callback: () => void): void
}
}

// for demo/debug purposes
window.SolidAuthClient = SolidAuthClient
console.log('Welcome to the solid-auth-client demo!')
Expand Down
12 changes: 6 additions & 6 deletions flow-typed/lib-defs.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
declare module 'auth-header' {
declare export function parse(wwwAuthHeader: string): object
declare export function parse(wwwAuthHeader: string): Object
}

declare module '@trust/oidc-rp' {
declare export default class RelyingParty {
provider: { url: string },
static from(data: object): Promise<RelyingParty>,
static from(data: Object): Promise<RelyingParty>,
static register(
issuer: string,
registration: object,
options: object
registration: Object,
options: Object
): Promise<RelyingParty>,
createRequest(options: object, storage: object): Promise<string>,
createRequest(options: Object, storage: Object): Promise<string>,
serialize(): string,
validateResponse(response: string, session: object): Promise<object>,
validateResponse(response: string, session: Object): Promise<Object>,
logout(): Promise<void>
}
}
Loading