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

ARC-0027: Provider Message Schema #272

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

kieranroneill
Copy link

@kieranroneill kieranroneill commented Jan 12, 2024

Summary

This proposal intends to outline a common message schema to be used in dApp/provider (wallet) communication.

The proposal attempts to build off the fundamental work of the previous ARCs; wallet transaction signing (ARC-0005), wallet address discovery (ARC-0006), wallet transaction network posting (ARC-0007) and wallet transaction signing & posting (ARC-0008), to comprehensively outline a common message schema, and to extend this schema with an aim to allow more robustness with multiple AVM (Algorand Virtual Machine) chains.

Aside from extending the schema of the previous ARCs, this proposal also adds a couple of new methods that aim to "fill the gap". These include:

  • A discovery method that is used to get information about providers such as what methods are supported and what chains.
  • A "disable" method that allows a dApp to remove itself from providers.

ARCs/arc-0027.md Outdated Show resolved Hide resolved
…stions

Co-authored-by: Doug Richar <drichar@gmail.com>
Copy link

@ehanoc ehanoc left a comment

Choose a reason for hiding this comment

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

I'm a big big fan of this proposal.

Overall, to finalize it, maybe we could include a reference implementation for us to test ourselves?

ARCs/arc-0027.md Outdated
@@ -0,0 +1,1611 @@
---
arc: 27
title: Web Extension Wallet Interface
Copy link

Choose a reason for hiding this comment

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

What do you think of keeping this agnostic to the platform? We could just say Wallet Interface for instance

ARCs/arc-0027.md Outdated
| Description | Benefits | Drawbacks |
|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| The global `window.algorand` object is overwritten by an injected script from a web extension's content script. This overwritten object will provide features that allows the dapp to interact with the wallet which may or may not conform to previous ARCs ([ARC-0005](./arc-0005.md#specification), [ARC-0006](./arc-0006.md#specification), [ARC-0007](./arc-0007.md#specification) or [ARC-0008](./arc-0008.md#specification)). | - Dapps will not have to install any external SDKs<br/>- Dapps do not need to know which wallet the user is using (if the injected wallet conforms to [ARC-0005](./arc-0005.md#specification), [ARC-0006](./arc-0006.md#specification), [ARC-0007](./arc-0007.md#specification) or [ARC-0008](./arc-0008.md#specification)) | - In the instance of multiple web extension wallets, another wallet extension may overwrite this object.<br/>- Once overwritten, the `window.algorand` object will only service the last web extension wallet that overwrote it. |
| A wallet provides a separate SDK that is installed by a dapp to interact with the wallet. | - Allows wallets full control over how dapps interact with wallets, ie. provide a bespoke UX. | - Dapps need to install each SDK separately, thereby increasing the amount of development time, and complexity, needed to implement each wallet separately. |
Copy link

Choose a reason for hiding this comment

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

Wouldn't this be a single SDK for dapp developers? They would just need to comply with the API, no?

Maybe that's something could be provided in the ARC as a reference implementation. Thoughts?

ARCs/arc-0027.md Outdated

The dapp will, itself, listen to broadcasted responses from any providers. Below is a simple diagram for the flow of data for an enable request:

![Simple BroadcastChannel API using web extensions](../assets/arc-0027/simple_message_bus.png)
Copy link

Choose a reason for hiding this comment

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

I like it, is there samples for us to include here and test?

Copy link
Author

Choose a reason for hiding this comment

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

I am separately developing an npm package, that is essentially an SDK wrapper around this, for wallets/dApps to install for minimum code. Similar to the Algorand Provider I built way back.

The UseWallet implementation of the Kibisis wallet uses it into interact with the Kibisis web extension wallet.

ARCs/arc-0027.md Outdated
* `reference`:
- **MUST** be `arc0027:sign_txns:response`

#### Sign Bytes
Copy link

Choose a reason for hiding this comment

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

I'm a fan of us supporting signing for multiple purposes and arbitrary data signing. But signBytes:

  • seems to give freedom to the app to define what purposes this can be used for with a simple string. Seems that it can be gamed to trick users to sign things that they shouldn't, even transactions.
  • Doesn't consider multiple encoding schemes
  • Validation of the content to be signed should be matched against a known schema?

That's one of the things i'm trying to address in ARC-52#SignMetadata is to enforce the context of what we are signing and validate it quickly from a list of possible schema templates (i.e authentication requests, messages, identity), so that the user doesn't have to understand msgpack encoding or CBOR and the wallet can still validate what is signing.

It's a longer conversation though.

Copy link
Author

Choose a reason for hiding this comment

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

I wholeheartedly agree. I have been playing with this with Algorand Provider + Kibisis and, if I recall, Kibisis displays the data if it is:

  • A valid UTF-8 string
  • A parseable JWT

For example, for JWTs, if it is correctly parsed it shows this screen:
Screen of Kibisis JWT signing

It also shows some warnings if the JWT has expired or the subject/sub of the JWT does not match the account to sign.

As you can workout, I am a fan of JWTs 😅

(It was actually the only reason I built Kibisis as I wanted to implement, for the then, app I was building to use user JWT authentication using an Algorand account)

But you are right, the schema of this function requires more work as it is not fit for consumption.

ARCs/arc-0027.md Outdated

## Abstract

Building off of the previous ARCs relating to; wallet transaction signing ([ARC-0005](./arc-0005.md#specification)), wallet address discovery ([ARC-0006](./arc-0006.md#specification)), wallet transaction network posting ([ARC-0007](./arc-0007.md#specification)) and wallet transaction signing & posting ([ARC-0008](./arc-0008.md#specification)), this proposal aims to extend and comprehensively outline a common interface between multiple web extension wallets and dapps by utilizing the pub/sub semantics of the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API">BroadcastChannel API</a>.
Copy link
Contributor

Choose a reason for hiding this comment

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

Using a BroadcastChannel is an interesting choice and would need a bit more inspection. AFAIK web extensions do not typically inject in iframes, with this approach we may be allowing embedded iframes to trigger a wallet popup as long as that origin is also open in a tab elsewhere.

Copy link
Contributor

@kewde kewde Feb 8, 2024

Choose a reason for hiding this comment

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

Do I understand it correctly that if multiple tabs are open and thus content scripts are listening to the BroadcastChannel, then they need to avoid registering multiple times? If registering multiple times is allowed, would the content script need to synchronize internally to ensure that it deals with e.g "signTxn" only once, as to not open 10 popups for each of the 10 tabs that are open?

ARCs/arc-0027.md Outdated
* `result.host`:
- **RECOMMENDED** a URL that points to a live website
* `result.icon`:
- **RECOMMENDED** be a URI that conforms to <a href="https://www.rfc-editor.org/rfc/rfc2397">[RFC-2397]</a>
Copy link
Contributor

@kewde kewde Feb 8, 2024

Choose a reason for hiding this comment

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

Can we make this mandatory? Having remote URI's here may make it harder to implement, and potentially more dangerous too.

Along with limiting the supported filetypes would be nice? 'svg+xml' | 'webp' | 'png' | 'gif' are the ones supported by wallet-standard.

- **MUST** be a code of one of the [errors](#errors)
* `message`:
- **SHOULD** be human-readable to allow for display to a user
* `providerId`:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we clarify if the providerId is static value or whether this is allowed to be a random value every time it is registered? If it is a static value, will we maintain a list somewhere of the "taken" values which we'll respect on a gentlemen's agreement, even though collisions are very rare.

ARCs/arc-0027.md Outdated
* `result.networks.methods`:
- **SHOULD** be one or all of `enable`, `postTxns`, `signAndPostTxns`, `signBytes` or `signTxns`
- **MAY** be empty
* `result.host`:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we mandate that this must be "https://"?

@kieranroneill kieranroneill changed the title ARC-0027: Web Extension Provider Interface ARC-0027: Provider Message Schema Apr 5, 2024
@kieranroneill kieranroneill linked an issue Apr 24, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ARC-0027] Add sign message schema [ARC-0027] Remove explicit reference to a web extension
5 participants