Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Implemented verifiable credentials specs #116

Merged
merged 16 commits into from Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 0 additions & 34 deletions lib/actions/__tests__/__snapshots__/uportActions-test.js.snap
Expand Up @@ -387,40 +387,6 @@ Object {
}
`;

exports[`creates an ADD_PENDING_ATTESTATION action 1`] = `
Object {
"_backup": true,
"address": "0x123afdasdfasdfasdf",
"claimType": "name",
"iss": "0xdsasdfasdf",
"options": Object {},
"type": "ADD_PENDING_ATTESTATION",
}
`;

exports[`creates an ADD_PENDING_ATTESTATION action 2`] = `
Object {
"_backup": true,
"address": "0x123afdasdfasdfasdf",
"claimType": "name",
"iss": "0xdsasdfasdf",
"options": Object {
"applicant_id": 1234,
},
"type": "ADD_PENDING_ATTESTATION",
}
`;

exports[`creates an REMOVE_PENDING_ATTESTATION action 1`] = `
Object {
"_backup": true,
"address": "0x123afdasdfasdfasdf",
"claimType": "name",
"iss": "0xdsasdfasdf",
"type": "REMOVE_PENDING_ATTESTATION",
}
`;

exports[`creates an STORE_ATTESTATION action 1`] = `
Object {
"_backup": true,
Expand Down
11 changes: 1 addition & 10 deletions lib/actions/__tests__/uportActions-test.js
Expand Up @@ -21,7 +21,7 @@ import { createIdentity, createAccount, verificationSMS, verificationCall, verif
resetIdentity, removeIdentity, refreshExternalUport, createEncryptionKey, storeEncryptionKey, storePututuToken, storeFuelToken, storeActivity, updateActivity, openActivity,
removeActivity, updateInteractionStats, storeAttestation, removeAttestation, saveIpfsProfile,
addImage, storeExternalUport, storeCurrentIdentity, saveSegmentId, addImageOnboarding, savePublicUport, callFaucet,
addPendingAttestation, removePendingAttestation, storeKeyChainLevel } from 'uPortMobile/lib/actions/uportActions.js'
storeKeyChainLevel } from 'uPortMobile/lib/actions/uportActions.js'

const address = '0x0102030405'
const mockedTimeStamp = 1516134091907
Expand Down Expand Up @@ -194,15 +194,6 @@ it('creates a REMOVE_ATTESTATION action', () => {
expect(removeAttestation(address, '0xdsasdfasdf')).toMatchSnapshot()
})

it('creates an ADD_PENDING_ATTESTATION action', () => {
expect(addPendingAttestation('0x123afdasdfasdfasdf', '0xdsasdfasdf', 'name')).toMatchSnapshot()
expect(addPendingAttestation('0x123afdasdfasdfasdf', '0xdsasdfasdf', 'name', {applicant_id: 1234})).toMatchSnapshot()
})

it('creates an REMOVE_PENDING_ATTESTATION action', () => {
expect(removePendingAttestation('0x123afdasdfasdfasdf', '0xdsasdfasdf', 'name')).toMatchSnapshot()
})

it('creates a SAVE_PUBLIC_UPORT action', () => {
expect(savePublicUport('0x123')).toMatchSnapshot()
})
Expand Down
23 changes: 0 additions & 23 deletions lib/actions/uportActions.js
Expand Up @@ -66,8 +66,6 @@ import {
CREATE_ENCRYPTION_KEY,
STORE_ENCRYPTION_KEY,
STORE_PUTUTU_TOKEN,
ADD_PENDING_ATTESTATION,
REMOVE_PENDING_ATTESTATION,
STORE_KEYCHAIN_LEVEL,
STORE_SECURITY_LEVEL,
SHARE_STATE_DUMP,
Expand Down Expand Up @@ -392,27 +390,6 @@ export function updateInteractionStats(address, party, interactionType) {
}
}

export function addPendingAttestation(address, iss, claimType, options = {}) {
return {
type: ADD_PENDING_ATTESTATION,
address,
iss,
claimType,
options,
_backup,
}
}

export function removePendingAttestation(address, iss, claimType) {
return {
type: REMOVE_PENDING_ATTESTATION,
address,
iss,
claimType,
_backup,
}
}

// Expects an attestation object not a token itself
// The attestations object is basically the JWT payload with the jwt added under the `token` key
// This is not meant to be called directly
Expand Down
Expand Up @@ -22,7 +22,6 @@ import { toClj, toJs } from 'mori'
import FakeNavigator from '../../testHelpers/FakeNavigator'
import renderer from 'react-test-renderer'
import { externalProfile } from 'uPortMobile/lib/selectors/requests'
import { requestedClaims } from 'uPortMobile/lib/selectors/attestations'

function lookupIssuer (address) {
return {address: '0x1bc5cbf71b068642fc5e89c5e3d0bdb3e366bc02', name: '0x1bc5cbf7...'}
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Notifications/index.js
Expand Up @@ -135,7 +135,7 @@ const mapStateToProps = (state) => (
{
lookupIssuer: (clientId) => toJs(externalProfile(state, clientId)),
notifications: notifications(state),
requested: (activity) => requestedClaims(state, activity && activity.requested)
requested: (activity) => activity.type === 'disclosure' ? requestedClaims(state, activity && activity.requested) : undefined
}
)

Expand Down
3 changes: 0 additions & 3 deletions lib/components/Request/types/Eip712SignCard.js
Expand Up @@ -36,7 +36,6 @@ import Status from 'uPortMobile/lib/components/shared/Status'
// Selectors
import { clientProfile, currentRequest } from 'uPortMobile/lib/selectors/requests'
import { publicUport, currentAddress, interactionStats, hasPublishedDID } from 'uPortMobile/lib/selectors/identities'
import { requestedClaims, verifiedClaimsByType } from 'uPortMobile/lib/selectors/attestations'
import { working, errorMessage } from 'uPortMobile/lib/selectors/processStatus'
import { endpointArn } from 'uPortMobile/lib/selectors/snsRegistrationStatus'

Expand Down Expand Up @@ -129,7 +128,6 @@ Eip712SignCard.propTypes = {
actType: PropTypes.string,
authorized: PropTypes.bool,
verified: PropTypes.object,
requested: PropTypes.object,
currentIdentity: PropTypes.object,
client: PropTypes.object,

Expand All @@ -146,7 +144,6 @@ const mapStateToProps = (state) => {
const networkName = network.name
const client = clientProfile(state)
const currentIdentity = toJs(publicUport(state))
const requested = requestedClaims(state, request && request.requested)
const unsignedClaim = request && request.typedData ? request.typedData : {}
const subject = request && request.subject ? request.subject : ''
const uportVerified = request && request.client_id ? Object.keys(verifiedByUport).indexOf(request.client_id) > -1 : false
Expand Down
3 changes: 0 additions & 3 deletions lib/components/Request/types/PersonalSignCard.js
Expand Up @@ -36,7 +36,6 @@ import Status from 'uPortMobile/lib/components/shared/Status'
// Selectors
import { clientProfile, currentRequest } from 'uPortMobile/lib/selectors/requests'
import { publicUport, currentAddress, interactionStats, hasPublishedDID } from 'uPortMobile/lib/selectors/identities'
import { requestedClaims, verifiedClaimsByType } from 'uPortMobile/lib/selectors/attestations'
import { working, errorMessage } from 'uPortMobile/lib/selectors/processStatus'
import { endpointArn } from 'uPortMobile/lib/selectors/snsRegistrationStatus'

Expand Down Expand Up @@ -129,7 +128,6 @@ PersonalSignCard.propTypes = {
actType: PropTypes.string,
authorized: PropTypes.bool,
verified: PropTypes.object,
requested: PropTypes.object,
currentIdentity: PropTypes.object,
client: PropTypes.object,

Expand All @@ -146,7 +144,6 @@ const mapStateToProps = (state) => {
const networkName = network.name
const client = clientProfile(state)
const currentIdentity = toJs(publicUport(state))
const requested = requestedClaims(state, request && request.requested)
const data = request && request.data ? request.data : {}
const subject = request && request.subject ? request.subject : ''
const uportVerified = request && request.client_id ? Object.keys(verifiedByUport).indexOf(request.client_id) > -1 : false
Expand Down
3 changes: 0 additions & 3 deletions lib/components/Request/types/VerificationSignCard.js
Expand Up @@ -36,7 +36,6 @@ import Status from 'uPortMobile/lib/components/shared/Status'
// Selectors
import { clientProfile, currentRequest } from 'uPortMobile/lib/selectors/requests'
import { publicUport, currentAddress, interactionStats, hasPublishedDID } from 'uPortMobile/lib/selectors/identities'
import { requestedClaims, verifiedClaimsByType } from 'uPortMobile/lib/selectors/attestations'
import { working, errorMessage } from 'uPortMobile/lib/selectors/processStatus'
import { endpointArn } from 'uPortMobile/lib/selectors/snsRegistrationStatus'

Expand Down Expand Up @@ -130,7 +129,6 @@ VerificationSignCard.propTypes = {
actType: PropTypes.string,
authorized: PropTypes.bool,
verified: PropTypes.object,
requested: PropTypes.object,
currentIdentity: PropTypes.object,
client: PropTypes.object,

Expand All @@ -147,7 +145,6 @@ const mapStateToProps = (state) => {
const networkName = network.name
const client = clientProfile(state)
const currentIdentity = toJs(publicUport(state))
const requested = requestedClaims(state, request && request.requested)
const unsignedClaim = request && request.unsignedClaim ? request.unsignedClaim : {}
const subject = request && request.subject ? request.subject : ''
const uportVerified = request && request.client_id ? Object.keys(verifiedByUport).indexOf(request.client_id) > -1 : false
Expand Down
5 changes: 3 additions & 2 deletions lib/components/Verifications/ExpirationItem.js
Expand Up @@ -21,7 +21,8 @@ import { Text, View, StyleSheet } from 'react-native'
import moment from 'moment'

// Styles
import { colors, font, fontLight } from 'uPortMobile/lib/styles/globalStyles'
import { colors, fontLight } from 'uPortMobile/lib/styles/globalStyles'
import { JWT_MS_CUTOFF } from 'uPortMobile/lib/selectors/attestations'

const styles = StyleSheet.create({
expirationDate: {
Expand All @@ -33,7 +34,7 @@ const styles = StyleSheet.create({
})
// Helpers
const ExpirationItem = (props) => {
let expirationDate = props.d && props.d >= 1000000000000 ? moment.unix(Math.floor(props.d / 1000)) : moment.unix(props.d)
let expirationDate = props.d && props.d >= JWT_MS_CUTOFF ? moment.unix(props.d) : moment.unix(props.d*1000)
return (
<View>
{expirationDate.isValid()
Expand Down
3 changes: 0 additions & 3 deletions lib/components/Verifications/VerificationListItem.js
Expand Up @@ -93,9 +93,6 @@ export function extractClaimType (verification) {
}

export function extractClaims (verification) {
if (verification.claimType) {
return 'pending'
}
const claim = verification.claim[Object.keys(verification.claim)[0]]
if (typeof claim === 'object') {
return Object.keys(claim).slice(0, 3).map(t => claim[t]).join(', ')
Expand Down
11 changes: 2 additions & 9 deletions lib/components/Verifications/Verifications.js
Expand Up @@ -22,10 +22,7 @@ import { connect } from 'react-redux'
import { toJs } from 'mori'

import VerificationList from 'uPortMobile/lib/components/Verifications/VerificationList'
import { removePendingAttestation } from 'uPortMobile/lib/actions/uportActions'

import { onlyPendingAndLatestAttestations,
pendingOrIssuedAttestationFor, pendingAttestationFor} from 'uPortMobile/lib/selectors/attestations'
import { onlyLatestAttestationsWithIssuer } from 'uPortMobile/lib/selectors/attestations'
import { externalProfile } from 'uPortMobile/lib/selectors/requests'
import { colors, font, textStyles } from 'uPortMobile/lib/styles/globalStyles'

Expand Down Expand Up @@ -74,9 +71,6 @@ export class Verifications extends React.Component {
}

render () {
// console.log( `pendingAttestations -> ${this.props.pendingAttestations}`)
// console.log( `pendingAttestationsFor -> ${this.props.pendingAttestationsFor}`)
// console.log( `pendingOrIssuedAttestationFor -> ${this.props.pendingOrIssuedAttestationFor}`)
return (
<View style={{padding: 10, flex: 1, backgroundColor: colors.white246, borderTopWidth: 1, borderColor: colors.white216}}>
{!this.props.attestations.length && <View>
Expand All @@ -97,14 +91,13 @@ export class Verifications extends React.Component {

Verifications.propTypes = {
attestations: PropTypes.array,
pendingAttestation: PropTypes.array,
lookupIssuer: PropTypes.func
}

const mapStateToProps = (state, ownProps) => {
return {
...ownProps,
attestations: onlyPendingAndLatestAttestations(state),
attestations: onlyLatestAttestationsWithIssuer(state),
lookupIssuer: (clientId) => toJs(externalProfile(state, clientId)),
address: currentAddress(state)
}
Expand Down
Expand Up @@ -53,13 +53,6 @@ const verificationNoExpiration = {
issuer
}

const pending = {
sub: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
claimType: 'employer',
iss: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
issuer
}

const complexVerification = {
sub: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
claim: {
Expand Down Expand Up @@ -97,17 +90,8 @@ describe('render VerificationListItem', () => {
expect(tree).toMatchSnapshot()
})

it('pending]', () => {
const tree = renderer.create(
<VerificationListItem
verification={pending}
selectVerification={handleClaimClick}
/>).toJSON()
expect(tree).toMatchSnapshot()
})

it('returns the verification claimType from the verification', () => {
expect(extractClaimType(pending)).toEqual('employer')
expect(extractClaimType(verification)).toEqual('employer')
})

it('extractClaims from the verification', () => {
Expand Down
Expand Up @@ -31,16 +31,6 @@ const issuer = {
name: 'Issuer Name'
}

const pendingAttestations = [{
sub: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
claim: { employer: 'Consensys AG' },
iss: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
iat: 1482268217249,
exp: 1482354617249,
token: 'tokenstring',
issuer
}]

const attestations = [
{
sub: '0x88647b5a94cd8347c8f76c7b79c85bbfbf0e13a9',
Expand Down Expand Up @@ -115,18 +105,7 @@ const simpleIdentity = {
},
token: '0014.TOKEN'
}
},
pendingAttestations: {
'0x1bc5cbf71b068642fc5e89c5e3d0bdb3e366bc01': {
nationalId: {applicant_id: 1234},
name: {}
},
'0x1bc5cbf71b068642fc5e89c5e3d0bdb3e366bc02': {
nationalId: {}
}

}
}
}}
const withIssuers = toClj({
external: {
'0x1bc5cbf71b068642fc5e89c5e3d0bdb3e366bc01': {
Expand All @@ -142,17 +121,6 @@ const uport = uportReducer(withIssuers, storeIdentity(simpleIdentity))
const withVerifications = {...emptyState, uport}
// 47,73,105
describe('rendering', () => {
it('both pending and issued verifications', () => {
const tree = renderer.create(
<FakeProvider state={emptyState}>
<Verifications
attestations={attestations}
navigator={new FakeNavigator()}
/>
</FakeProvider>
).toJSON()
expect(tree).toMatchSnapshot()
})

it('only issued verifications', () => {
const tree = renderer.create(
Expand All @@ -166,18 +134,6 @@ describe('rendering', () => {
expect(tree).toMatchSnapshot()
})

it('only pending verifications', () => {
const tree = renderer.create(
<FakeProvider state={emptyState}>
<Verifications
attestations={pendingAttestations}
navigator={new FakeNavigator()}
/>
</FakeProvider>
).toJSON()
expect(tree).toMatchSnapshot()
})

it('empty', () => {
const tree = renderer.create(
<FakeProvider state={emptyState}>
Expand Down
2 changes: 1 addition & 1 deletion lib/components/newRequest/index.js
Expand Up @@ -143,7 +143,7 @@ export class Request extends Component {
case 'sign':
return (<TransactionCard />)
case 'disclosure':
return (<DisclosureCard />)
return (<DisclosureCard navigator={this.props.navigator} />)
}
}
// Render actual cards here like in old RequestCard
Expand Down