-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement sign message method (#28)
* feat: implement sign message functionality * docs: add tutorials on signing a message * docs: update mentions of old types to use new types * docs: update readme to reflect use of event target * chore: squash
- Loading branch information
1 parent
fe34735
commit ef1e929
Showing
31 changed files
with
460 additions
and
62 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
import TOCInline from '@theme/TOCInline'; | ||
|
||
# Signing A Message | ||
|
||
<TOCInline | ||
maxHeadingLevel={4} | ||
toc={toc} | ||
/> | ||
|
||
## Overview | ||
|
||
Providers, if supported, can sign an arbitrary UTF-8 string. | ||
|
||
## Signing a message | ||
|
||
<Tabs | ||
defaultValue="javascript" | ||
values={[ | ||
{ label: 'Javascript', value: 'javascript' }, | ||
{ label: 'TypeScript', value: 'typescript' }, | ||
]}> | ||
<TabItem value="javascript"> | ||
|
||
```js | ||
// initialized client | ||
client.onSignMessage(({ error, result }) => { | ||
if (error) { | ||
console.error('error:', error); | ||
|
||
return; | ||
} | ||
|
||
console.log(result); | ||
/* | ||
{ | ||
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', | ||
signature: 'gqNzaWfEQ...', | ||
} | ||
*/ | ||
}); | ||
|
||
// send a sign message request | ||
client.signMessage({ | ||
message: 'Hello humie!', | ||
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', | ||
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U', | ||
}); | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="typescript"> | ||
|
||
```typescript | ||
import { IAVMWebClientCallbackOptions } from '@agoralabs-sh/avm-web-provider'; | ||
|
||
// initialized client | ||
client.onSignMessage(({ error, result }: IAVMWebClientCallbackOptions) => { | ||
if (error) { | ||
console.error('error:', error); | ||
|
||
return; | ||
} | ||
|
||
console.log(result); | ||
/* | ||
{ | ||
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', | ||
signature: 'gqNzaWfEQ...', | ||
} | ||
*/ | ||
}); | ||
|
||
// send a sign message request | ||
client.signMessage({ | ||
message: 'Hello humie!', | ||
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e', | ||
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U', | ||
}); | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
:::caution | ||
|
||
If this method is not supported, then a [`MethodNotSupportedError`](../../api-reference/errors#methodnotsupportederror) will be sent in the `error` parameter. | ||
|
||
::: | ||
|
||
:::caution | ||
|
||
If the signer is not known, or not authorized, then a [`UnauthorizedSignerError`](../../api-reference/errors#unauthorizedsignererror) will be sent in the `error` parameter. | ||
|
||
::: |
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.