Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semaphore passkey #20

Open
wants to merge 80 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
27fb574
wrap createproof with retry
saberistic Oct 2, 2024
dafd357
💄
saberistic Oct 2, 2024
c932c1d
skip mismatched robinhood url
saberistic Oct 2, 2024
2ce3112
remove log
saberistic Oct 2, 2024
4cdcbf4
lint
saberistic Oct 2, 2024
c2962e9
request menu: reduce text size for readbility
asa93 Oct 2, 2024
ebc61e3
only notarize once, brush up bookmarks
saberistic Oct 3, 2024
76e6390
fix build error
saberistic Oct 3, 2024
bf3f710
use regex for pattern matching
saberistic Oct 3, 2024
8838cb6
remove temp workaround
saberistic Oct 3, 2024
bcd6128
fix bad updates
saberistic Oct 3, 2024
339cc03
fix requests table size column
asa93 Oct 4, 2024
a97e099
creating branch
AlwaysHungrie Oct 7, 2024
eccec6c
cleaned up settings page ui
AlwaysHungrie Oct 7, 2024
e3a8960
fix identity storage logic and key info card in attestation details
AlwaysHungrie Oct 7, 2024
4b6e05c
buton to copy request, filter styleshee requests
asa93 Oct 8, 2024
db6a597
add new websockify url from k8s
asa93 Oct 8, 2024
44132b9
remove font
asa93 Oct 9, 2024
8ac5208
remove font
asa93 Oct 9, 2024
474d8ed
add config type with assertions and example
asa93 Oct 9, 2024
4ce0667
config: remove sig, add contains
asa93 Oct 9, 2024
d15879f
provider: remove url field, create type for config
asa93 Oct 10, 2024
eadc714
fix type issue
asa93 Oct 10, 2024
73690c4
fix other type issue
asa93 Oct 10, 2024
29349b3
fix notarize bug
asa93 Oct 10, 2024
fab2a37
comment type
asa93 Oct 11, 2024
69efe59
Merge branch 'retry-proof' into fix-attestation-view
asa93 Oct 11, 2024
048765d
type
asa93 Oct 11, 2024
12abdba
rename package and fix repo
asa93 Oct 11, 2024
db2edda
fix body for post requests
asa93 Oct 11, 2024
e03e9a6
Merge branch 'retry-proof' into semaphore-identity
asa93 Oct 14, 2024
4154526
up package lock
asa93 Oct 14, 2024
e521d45
remove error display
asa93 Oct 15, 2024
a546a4f
fix copy request
asa93 Oct 15, 2024
5ebe611
add wildcard end of regex
asa93 Oct 16, 2024
696b22d
regex: remove characters after ?
asa93 Oct 16, 2024
19417fb
beautify json string, increment id automatically
asa93 Oct 16, 2024
e8007df
use bookmark reducer
asa93 Oct 16, 2024
8d21dd7
copy current tab url as target url
asa93 Oct 16, 2024
4cdfe79
reduce steps for manual notarization
asa93 Oct 16, 2024
0141169
remove legacy field maxTranscriptSize etc
asa93 Oct 16, 2024
76a1f64
remove legacy func
asa93 Oct 16, 2024
916e33a
bigger icons
asa93 Oct 16, 2024
e011fdd
remove useless
asa93 Oct 16, 2024
8bd6071
disable pugin
asa93 Oct 16, 2024
ea98de0
settings: fix ui
asa93 Oct 16, 2024
8951fbf
options: more fixes
asa93 Oct 17, 2024
1c4ffe6
settings: center ui
asa93 Oct 17, 2024
3995dd1
use reducer for identity
asa93 Oct 17, 2024
f7007d3
Merge branch 'bug-ui-fix' into semaphore-identity
asa93 Oct 17, 2024
fb79c55
bump version
asa93 Oct 17, 2024
8c011a8
deserialize new attestation format
asa93 Oct 19, 2024
8ae87d2
fix bug attribute
asa93 Oct 19, 2024
7704349
ui
asa93 Oct 19, 2024
f3c40fb
Merge branch 'bug-ui-fix' into semaphore-identity
asa93 Oct 19, 2024
eb914ae
include identity commitment as header
asa93 Oct 20, 2024
1fca8d8
Merge branch 'main' into semaphore-identity
asa93 Oct 20, 2024
f03cce2
passkey wip
AlwaysHungrie Oct 21, 2024
2c98364
misc
asa93 Oct 21, 2024
011c014
bump version
asa93 Oct 22, 2024
5c6541b
use new version of eternis/tlsn-js
asa93 Oct 22, 2024
e3127bd
fix attribute overlap
asa93 Oct 23, 2024
30b0cba
attribute ui
asa93 Oct 23, 2024
91bffc0
remove useless properties
asa93 Oct 23, 2024
ea05b2a
passkey auth using floating window
AlwaysHungrie Oct 24, 2024
134d247
merged with main
AlwaysHungrie Oct 24, 2024
519130b
build fix and clean unused files
AlwaysHungrie Oct 24, 2024
2fea5ab
Merge branch 'semaphore-identity' into semaphore-passkey
AlwaysHungrie Oct 24, 2024
f99a91a
fix reducer error in offscreen
asa93 Oct 24, 2024
9deaf37
update default notary
asa93 Oct 26, 2024
55d225c
add logs
asa93 Oct 28, 2024
9ce60f5
add buffer keyword
asa93 Oct 28, 2024
6a32497
add keyword
asa93 Oct 28, 2024
01b634e
fix buffer bug
asa93 Oct 28, 2024
aa4df3e
log more
asa93 Oct 28, 2024
e8c4c20
update notarizedAt of bookmark when deleting attestations
asa93 Oct 28, 2024
abc66e3
Merge branch 'semaphore-identity' into semaphore-passkey
AlwaysHungrie Oct 29, 2024
3633be7
fixed sending identity while creating proof
AlwaysHungrie Oct 29, 2024
038aa4d
create identity/unlock without passkey
AlwaysHungrie Nov 8, 2024
0e2d43e
resolved conflicts, using updated identity manager that uses redux
AlwaysHungrie Nov 8, 2024
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
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@sardinefish/x509": "^1.2.1",
"@semaphore-protocol/identity": "^4.3.0",
"@shadcn/ui": "^0.0.4",
"@simplewebauthn/browser": "^11.0.0",
"async-mutex": "^0.4.0",
"axios": "^1.7.7",
"buffer": "^6.0.3",
Expand Down
Binary file added passkey.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions src/components/NavHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
return titles[step] || 'Pangea';
};

const handleBackClick = (path: string, navigate: any) => {

Check warning on line 26 in src/components/NavHeader/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const steps = path.split('/');

// special case to handle webiste history path
Expand Down Expand Up @@ -78,8 +78,8 @@
pathname: string;
navigate: (path: string) => void;
}) {
const { error, isValid } = useRemoteAttestation();

Check warning on line 81 in src/components/NavHeader/index.tsx

View workflow job for this annotation

GitHub Actions / lint

'error' is assigned a value but never used
const [isExtensionEnabled, setIsExtensionEnabled] = useExtensionEnabled();

Check warning on line 82 in src/components/NavHeader/index.tsx

View workflow job for this annotation

GitHub Actions / lint

'setIsExtensionEnabled' is assigned a value but never used
const [extensionStatus, setExtensionStatus] = useState<boolean | null>(null);

useEffect(() => {
Expand Down Expand Up @@ -142,6 +142,10 @@
return 'Disabled';
};

if (pathname === '/lock') {
return null;
}

return (
<div className="flex flex-nowrap flex-shrink-0 flex-row items-center relative gap-2 py-4 cursor-default bg-white w-full border-[#E4E6EA] border-b">
{pathname !== '/home' ? (
Expand Down
122 changes: 122 additions & 0 deletions src/entries/Background/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const charwise = require('charwise');

import { BookmarkManager } from '../../reducers/bookmarks';
import { AttestationObject } from '@eternis/tlsn-js';

export enum BackgroundActiontype {
get_requests = 'get_requests',
clear_requests = 'clear_requests',
Expand Down Expand Up @@ -88,6 +89,16 @@ export enum BackgroundActiontype {
get_logging_level = 'get_logging_level',
prepare_notarization = 'prepare_notarization',
get_notarization_status = 'get_notarization_status',
request_create_identity = 'request_create_identity',
request_unlock_extension = 'request_unlock_extension',
unlock_extension = 'unlock_extension',
close_auth_popup = 'close_auth_popup',
identity_updated = 'identity_updated',
}

export enum AuthActiontype {
web_authn_authenticate = 'web_authn_authenticate',
web_authn_register = 'web_authn_register',
}

export type BackgroundAction = {
Expand Down Expand Up @@ -136,6 +147,8 @@ export type RequestHistory = {
type?: string;
};

let identitySecret: string | undefined = undefined;

export const initRPC = () => {
browser.runtime.onMessage.addListener(
(request, sender, sendResponse): any => {
Expand Down Expand Up @@ -194,6 +207,15 @@ export const initRPC = () => {
return true;
case BackgroundActiontype.get_notarization_status:
return handleGetNotarizationStatus(request);
case BackgroundActiontype.request_unlock_extension:
return handleRequestUnlockExtension(request);
case BackgroundActiontype.request_create_identity:
return handleRequestCreateIdentity(request);
case BackgroundActiontype.close_auth_popup:
return handleCloseAuthPopup(request);
case BackgroundActiontype.identity_updated:
return handleIdentityUpdated(request);
default:
break;
}
},
Expand Down Expand Up @@ -305,6 +327,7 @@ async function handleRetryProveReqest(
...req,
notaryUrl,
websocketProxyUrl,
identitySecret,
},
});

Expand Down Expand Up @@ -358,6 +381,7 @@ export async function handleProveRequestStart(
body,
notaryUrl,
websocketProxyUrl,
identitySecret,
},
});

Expand Down Expand Up @@ -410,6 +434,7 @@ async function runPluginProver(request: BackgroundAction, now = Date.now()) {
body,
notaryUrl,
websocketProxyUrl,
identitySecret,
},
});
}
Expand Down Expand Up @@ -846,6 +871,7 @@ async function handleNotarizeRequest(request: BackgroundAction) {
body,
notaryUrl,
websocketProxyUrl,
identitySecret,
},
});
} catch (e) {
Expand Down Expand Up @@ -1066,3 +1092,99 @@ async function handleRunPluginCSRequest(request: BackgroundAction) {

return defer.promise;
}

let authWindow: number | undefined = undefined;
const createAuthPopup = async (left: number, top: number, width: number) => {
const popup = await chrome.windows.create({
url: 'auth.html',
type: 'panel',
width,
height: 1,
left,
top,
focused: true,
state: 'normal',
});
authWindow = popup.id;
};

async function handleRequestUnlockExtension(request: BackgroundAction) {
try {
const { left, top, width } = request.data;
await createAuthPopup(left, top, width);
setTimeout(() => {
chrome.runtime.sendMessage({
type: AuthActiontype.web_authn_authenticate,
});
}, 300);
} catch (e) {
console.error('error', e);
}
}

async function handleRequestCreateIdentity(request: BackgroundAction) {
try {
const { left, top, width, username, userId } = request.data;
if (!username || !userId) {
throw new Error('username and userId are required');
}

await createAuthPopup(left, top, width);
setTimeout(() => {
chrome.runtime.sendMessage({
type: AuthActiontype.web_authn_register,
data: {
username,
userId,
},
});
}, 300);
} catch (e) {
console.error('error', e);
}
}

async function handleCloseAuthPopup(request: BackgroundAction) {
try {
if (authWindow) {
// Remove all popup windows otherwise popup.html will keep stacking up
// await chrome.windows.remove(authWindow);
const windows = await chrome.windows.getAll();
await Promise.all(
windows.map(async (window) => {
if (window.type === 'popup') {
await chrome.windows.remove(window.id!);
}
}),
);

// Calling open popup forces the popup to remain open as focus is lost from previous remove calls
await chrome.windows.create({
url: 'popup.html',
type: 'popup',
width: 1,
height: 1,
});

// send message unlock extension
if (request && request.data && request.data.userId) {
chrome.runtime.sendMessage({
type: BackgroundActiontype.unlock_extension,
data: {
userId: request.data.userId,
},
});
}

authWindow = undefined;
}
} catch (e) {
console.error('error', e);
}
}

async function handleIdentityUpdated(request: BackgroundAction) {
if (request.data.identitySecret) {
identitySecret = request.data.identitySecret;
}
}
11 changes: 8 additions & 3 deletions src/entries/Offscreen/Offscreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { BackgroundActiontype } from '../Background/rpc';
import browser from 'webextension-polyfill';
import { Proof } from '../../utils/types';
import { Method } from '@eternis/tlsn-js/wasm/pkg';
import { IdentityManager } from '../../reducers/identity';
import { Identity } from '@semaphore-protocol/identity';

const { init, verify_attestation, Prover, NotarizedSession, TlsProof }: any =
Comlink.wrap(new Worker(new URL('./worker.ts', import.meta.url)));
Expand Down Expand Up @@ -212,6 +212,7 @@ async function createProof(options: {
};
body?: any;
id: string;
identitySecret: string;
}): Promise<AttestationObject> {
const {
url,
Expand All @@ -221,10 +222,14 @@ async function createProof(options: {
notaryUrl,
websocketProxyUrl,
id,
identitySecret,
} = options;

const identityManager = new IdentityManager();
const identity = await identityManager.getIdentity();
if (!identitySecret) {
throw new Error('IdentitySecret is required, extension is not unlocked');
}

const identity = new Identity(identitySecret);

const hostname = urlify(url)?.hostname || '';
const notary = NotaryServer.from(notaryUrl);
Expand Down
23 changes: 22 additions & 1 deletion src/entries/Popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,18 @@ import { getConnection } from '../Background/db';
import NavHeader from '../../components/NavHeader';
import Websites from '../../pages/Websites';
import AttestationDetails from '../../pages/AttestationDetails';
import Locked from '../../pages/Locked';
import {
initIdentity,
setIdentity,
useIdentity,
} from '../../reducers/identity';

const Popup = () => {
const dispatch = useDispatch();
const navigate = useNavigate();
const location = useLocation();
const { loading, identity } = useIdentity();

useEffect(() => {
(async () => {
Expand All @@ -70,12 +77,18 @@ const Popup = () => {
type: BackgroundActiontype.get_prove_requests,
data: tab?.id,
});

dispatch(await initIdentity());
})();
}, []);

useEffect(() => {
chrome.runtime.onMessage.addListener((request) => {
chrome.runtime.onMessage.addListener(async (request) => {
switch (request.type) {
case BackgroundActiontype.unlock_extension: {
dispatch(await setIdentity(request.data.userId));
break;
}
case BackgroundActiontype.push_action: {
if (
request.data.tabId === store.getState().requests.activeTab?.id ||
Expand All @@ -95,6 +108,14 @@ const Popup = () => {
});
}, []);

if (loading) {
return <></>;
}

if (!identity) {
return <Locked />;
}

return (
<div className="flex flex-col w-full h-full overflow-hidden bg-[#F9FAFB]">
<NavHeader pathname={location.pathname} navigate={navigate} />
Expand Down
10 changes: 10 additions & 0 deletions src/entries/Popup/auth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Eternis Passkey Authentication</title>
</head>
<body>

</body>
</html>
Loading
Loading