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

Feat/connect rtc #8

Merged
merged 24 commits into from
Apr 24, 2024
Merged

Feat/connect rtc #8

merged 24 commits into from
Apr 24, 2024

Conversation

PhearZero
Copy link
Member

@PhearZero PhearZero commented Apr 10, 2024

ℹ Overview

  • adds authenticated signaling service
  • adds shared core module to prevent encoding errors (to be replaced by algo-models in the future)
  • adds example demo for txn messages

📝 Related Issues

🛑 Blocked by

✅ Acceptance:

  • Conventional Commits

@PhearZero PhearZero added the enhancement New feature or request label Apr 10, 2024
@PhearZero PhearZero self-assigned this Apr 10, 2024
# Conflicts:
#	package-lock.json
#	services/liquid-auth-api-js/package.json
#	services/liquid-auth-api-js/src/app.controller.ts
…ect-rtc

# Conflicts:
#	package-lock.json
#	services/liquid-auth-api-js/src/connect/connect.controller.ts
#	services/liquid-auth-api-js/src/connect/connect.module.ts
#	sites/dapp-ui/src/pages/home/ConnectModal.tsx
@PhearZero PhearZero marked this pull request as ready for review April 12, 2024 13:03
- adds tests to the core library
- adds ci for pull requests
…connect-rtc

# Conflicts:
#	sites/dapp-ui/src/pages/home/ConnectModal.tsx
- removes awesome-algorand tweetnacl fork

- Limit dependency on WebSockets to signaling
- Allow bidirectional communication between peers
- Enforce locality of device?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we enforce it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could if we remove the STUN/TURN servers but we would lose a decent percentage of devices behind symmetric NAT

Copy link
Collaborator

@kylebeee kylebeee Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is enforced locality even possible if apple / chrome sync passkeys across devices?

Not sure about chrome but apple really doesn't adhere to the standard well

https://www.slashid.dev/blog/passkeys-deepdive/#:~:text=Passkeys%20and%20traditional%20platform%20authenticator,event%20of%20a%20device%20compromise.

"impossible to verify the device type used to generate a key, and hence the trustworthiness of the key and its metadata. In fact, the lack of an attestation statement means that you can’t prove the key has been stored, or even generated, safely because you can’t infer properties/provenance of the authenticator."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylebeee Enforcing locality of the WebRTC peer channel, limiting discovery to only local addresses (no STUN/TURN)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the decision is no enforcing locality we should remove this bullet IMO

@@ -47,10 +56,12 @@ async function bootstrap() {
ttl: 20000,
});

app.enableCors();

const sessionHandler = session({
secret: 'my-secret',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

@PhearZero PhearZero Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires CORS for hosting as a third party API, this may be a requirement if projects can't integrate the service as a proxy/side-car. We can remove it for now but we should consider the following:

  • Hosting from a different domain than the rendered application
  • With a different domain, we require third-party cookies which are deprecated and will only have partial support by end of 2024 with eventual removal*

*Future techniques will involve device fingerprinting or assigning ID's from the service to the devices local storage. For now, it's a hard rule that the service must be the request layer and operate as a sidecar/proxy

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I wasn't clear with my comment here. I was referring to secret: 'my-secret'. can we change it? reading from env maybe? something else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely read this from the env, could be a new ticket

clients/liquid-auth-client-js/package.json Outdated Show resolved Hide resolved
clients/liquid-auth-client-js/src/assertion.ts Outdated Show resolved Hide resolved
clients/liquid-auth-client-js/src/assertion.ts Outdated Show resolved Hide resolved
clients/liquid-auth-core/src/encoding.ts Show resolved Hide resolved
clients/liquid-auth-core/src/encoding.ts Show resolved Hide resolved
clients/liquid-auth-client-js/src/assertion.ts Outdated Show resolved Hide resolved
clients/liquid-auth-client-js/src/assertion.ts Outdated Show resolved Hide resolved
clients/liquid-auth-client-js/tests/encoding.test.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@kylebeee kylebeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few comments, otherwise LGTM

Copy link
Collaborator

@kylebeee kylebeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

}
return await fetch(`/assertion/request/${credId}`, {
...DEFAULT_FETCH_OPTIONS,
}).then((r) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance fetch throws an exception? I don't think we handle that if that's the case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes fetch can fail to get the URL, handling the error from the call site is good here since it's client/sdk code. We handle the invalid responses and let all other errors bubble to the call site.

client-gen.sh Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't find any mention of this in the readme

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly in the docs branch to limit merge conflicts with the unit tests

* @param key
* @deprecated
*/
sign(key: string | Account | Uint8Array | SignKeyPair): this {
Copy link
Contributor

@ori-shem-tov ori-shem-tov Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need signing capabilities in the client?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface is marked as deprecated. We will need to refactor it at some point for extension wallets but it's largely been replaced by the Signaling Client and the FIDO Liquid Extension

super();
this.url = url;
this.socket = io(url, options);
globalThis.socket = this.socket;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to set the globalThis?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convenience for using in projects, eventually it will be attached to the standard algorand namespace the other wallet providers use.

}

static generateRequestId() {
//TODO: replace with toBase64URL(nacl.randomBytes(nacl.sign.seedLength)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be hard to add

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs some changes in the API and Android client, we could kick off a new ticket to harden the requestId

* @param config
*/
async peer(
requestId: any,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be refactored to a encoded string when we harden the requestId. It's any to signal it's going to change/not stable API.

@ori-shem-tov
Copy link
Contributor

LGTM

@PhearZero PhearZero merged commit 0a37622 into develop Apr 24, 2024
2 checks passed
@PhearZero PhearZero deleted the feat/connect-rtc branch May 4, 2024 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🧹 Instructions required in README 🧹 Fully dockerize dev enviroment
3 participants