-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce the enable() interface (prompts user) (#20)
* Introduce the enable() interface * Provider * Add auth requests to state * injector comments * Background extension list, spprove & reject * Cleanups * Untested, but the UI parts are there (test next) * linting * Not pretty, but seems to auth * Small styling adjustments * Adjust Box layout slightly * Small styling adjustments * signing -> transactions * isDanger for links * Styling defaults
- Loading branch information
Showing
34 changed files
with
582 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2019 @polkadot/extension-ui authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the Apache-2.0 license. See the LICENSE file for details. | ||
|
||
import { MessageAuthorize } from '@polkadot/extension/background/types'; | ||
import { OnActionFromCtx } from '../../components/types'; | ||
|
||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { ActionBar, Box, Button, Link, defaults, withOnAction } from '../../components'; | ||
import { approveAuthRequest, rejectAuthRequest } from '../../messaging'; | ||
|
||
type Props = { | ||
authId: number, | ||
className?: string, | ||
isFirst: boolean, | ||
onAction: OnActionFromCtx, | ||
request: MessageAuthorize, | ||
url: string | ||
}; | ||
|
||
function Request ({ authId, className, isFirst, onAction, request: { origin }, url }: Props) { | ||
const onApprove = (): Promise<void> => | ||
approveAuthRequest(authId) | ||
.then(() => onAction()) | ||
.catch(console.error); | ||
const onReject = (): void => { | ||
rejectAuthRequest(authId) | ||
.then(() => onAction()) | ||
.catch(console.error); | ||
}; | ||
|
||
return ( | ||
<Box className={className}> | ||
<div>The application, identified as <div className='tab-name'>{origin}</div> is requesting access from <div className='tab-url'>{url}</div> to the accounts and signing capabilities of this extension. Only approve the request if you trust the application.</div> | ||
<ActionBar> | ||
<Link isDanger onClick={onReject}>Reject</Link> | ||
</ActionBar> | ||
{isFirst && ( | ||
<Button | ||
label='Yes, allow this application access' | ||
onClick={onApprove} | ||
/> | ||
)} | ||
</Box> | ||
); | ||
} | ||
|
||
export default withOnAction(styled(Request)` | ||
.tab-name, | ||
.tab-url { | ||
color: ${defaults.linkColor}; | ||
display: inline-block; | ||
} | ||
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2019 @polkadot/extension-ui authors & contributors | ||
// This software may be modified and distributed under the terms | ||
// of the Apache-2.0 license. See the LICENSE file for details. | ||
|
||
import { AuthRequestsFromCtx } from '../../components/types'; | ||
|
||
import React from 'react'; | ||
|
||
import { Header, withAuthRequests } from '../../components'; | ||
import Request from './Request'; | ||
|
||
type Props = { | ||
requests: AuthRequestsFromCtx | ||
}; | ||
|
||
function Authorize ({ requests }: Props) { | ||
return ( | ||
<div> | ||
<Header label='authorize' /> | ||
{requests.map(([id, request, url], index) => ( | ||
<Request | ||
authId={id} | ||
isFirst={index === 0} | ||
key={id} | ||
request={request} | ||
url={url} | ||
/> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export default withAuthRequests(Authorize); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.