Skip to content

Commit

Permalink
Merge pull request #3310 from superhero-com/feature/update-deep-link-…
Browse files Browse the repository at this point in the history
…schema

Rename sign JWT deep link and update deep link schema
  • Loading branch information
CedrikNikita authored Oct 15, 2024
2 parents d370a9d + fc44dbe commit 04d94be
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
29 changes: 25 additions & 4 deletions docs/deep-link-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ https://wallet.superhero.com/address
### Example

```
https://wallet.superhero.com/address?x-success=https%3A%2F%2Ftest.com%2Fsuccess-connection%3Faddress%3D%7Baddress%7D%26networkdId%3D%7BnetworkId%7D&x-cancel=https%3A%2F%2Ftest.com%2Ffail-connection
https://wallet.superhero.com/address?x-success=https%3A%2F%2Fexample.com%2Fsuccess-connection%3Faddress%3D%7Baddress%7D%26networkdId%3D%7BnetworkId%7D&x-cancel=https%3A%2F%2Fexample.com%2Ffail-connection
```


Expand Down Expand Up @@ -58,10 +58,10 @@ const url = `https://wallet.superhero.com/sign-transaction?${query.toString()}&x

```
# broadcast set to true
https://wallet.superhero.com/sign-transaction?transaction=tx_%2BFEMAaEB915T9XgiInpYtGMJXW2rZXyrgEV0vmLeC%2BH5UnnQkDehAfdeU%2FV4IiJ6WLRjCV1tq2V8q4BFdL5i3gvh%2BVJ50JA3C4YPJvVhyAAAAYAYTgEV&networkId=ae_uat&broadcast=true&x-success=https%3A%2F%2Ftest.com%2Fsuccess-connection%3Ftransaction-hash%3D%7Btransaction-hash%7D&x-cancel=https%3A%2F%2Ftest.com%2Ffail-connection
https://wallet.superhero.com/sign-transaction?transaction=tx_%2BFEMAaEB915T9XgiInpYtGMJXW2rZXyrgEV0vmLeC%2BH5UnnQkDehAfdeU%2FV4IiJ6WLRjCV1tq2V8q4BFdL5i3gvh%2BVJ50JA3C4YPJvVhyAAAAYAYTgEV&networkId=ae_uat&broadcast=true&x-success=https%3A%2F%2Fexample.com%2Fsuccess-connection%3Ftransaction-hash%3D%7Btransaction-hash%7D&x-cancel=https%3A%2F%2Fexample.com%2Ffail-connection
# broadcast set to false
https://wallet.superhero.com/sign-transaction?transaction=tx_%2BFEMAaEB915T9XgiInpYtGMJXW2rZXyrgEV0vmLeC%2BH5UnnQkDehAfdeU%2FV4IiJ6WLRjCV1tq2V8q4BFdL5i3gvh%2BVJ50JA3C4YPJvVhyAAAAYAYTgEV&networkId=ae_uat&x-success=https%3A%2F%2Ftest.com%2Fsuccess-transaction-signing%3Ftransaction%3D%7Btransaction%7D&x-cancel=https%3A%2F%2Ftest.com%2Ffail-transaction-signing
https://wallet.superhero.com/sign-transaction?transaction=tx_%2BFEMAaEB915T9XgiInpYtGMJXW2rZXyrgEV0vmLeC%2BH5UnnQkDehAfdeU%2FV4IiJ6WLRjCV1tq2V8q4BFdL5i3gvh%2BVJ50JA3C4YPJvVhyAAAAYAYTgEV&networkId=ae_uat&x-success=https%3A%2F%2Fexample.com%2Fsuccess-transaction-signing%3Ftransaction%3D%7Btransaction%7D&x-cancel=https%3A%2F%2Fexample.com%2Ffail-transaction-signing
```

## Sign a message
Expand All @@ -84,5 +84,26 @@ https://wallet.superhero.com/sign-message
### Example

```
https://wallet.superhero.com/sign-message?message=test&x-success=https%3A%2F%2Ftest.com%2Fsuccess-message-sign%3Fsignature%3D%7Bsignature%7D%26address%3D%7Baddress%7D&x-cancel=https%3A%2F%2Ftest.com%2Ffail-message-sign
https://wallet.superhero.com/sign-message?message=test&x-success=https%3A%2F%2Fexample.com%2Fsuccess-message-sign%3Fsignature%3D%7Bsignature%7D%26address%3D%7Baddress%7D&x-cancel=https%3A%2F%2Fexample.com%2Ffail-message-sign
```

## Sign a JWT

```bash
https://wallet.superhero.com/sign-jwt
? payload=<payload>
& x-success=<success-url>
& x-cancel=<cancel-url>
```

|URL Params|Description|
|--|--|
|`payload` (required)| Payload is the JWT.|
|`x-success` (required)| This is a callback URL in case user signs the message. Callback **must** contain: <br> - `{signed-payload}` parameter in order to get signed payload; <br> - `{address}` parameter in order to get current address.|
|`x-cancel` (required)| This is a callback URL in case user rejected to sign the message.|

### Example

```
https://wallet.superhero.com/sign-jwt?payload=%7B%22test%22%3A1%7D&x-success=https%3A%2F%2Fexample.com%3Fsigned-payload%3D%7Bsigned-payload%7D&x-cancel=https%3A%2F%2Fexample.com%2Ffail-sign-jwt
```
4 changes: 2 additions & 2 deletions src/popup/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,8 @@ export const routes: WalletAppRouteConfig[] = [
},
},
{
name: 'jwt-sign',
path: '/jwt-sign',
name: 'sign-jwt',
path: '/sign-jwt',
component: JwtSign,
meta: {
title: 'signMessage',
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/integration/deeplinks.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('Test cases for deeplinks', () => {
it.skip('JWT signing and verifying signature', () => {
cy.login(
{},
`/jwt-sign?payload=${encodedJWTPayload}`
`/sign-jwt?payload=${encodedJWTPayload}`
+ `&x-success=${encodedTestDeploymentUrl}%2Faccount%3F%7Bsigned-payload%7D`
+ `&x-cancel=${encodedTestDeploymentUrl}`,
)
Expand All @@ -147,7 +147,7 @@ describe('Test cases for deeplinks', () => {
});

it('JWT signing from superhero', () => {
cy.login({}, '/jwt-sign?payload=%7B%22a%22%3A1%2C%22b%22%3A2%7D&x-success=https%3A%2F%2Fchat.superhero.com&x-cancel=https%3A%2F%2Fchat.superhero.com')
cy.login({}, '/sign-jwt?payload=%7B%22a%22%3A1%2C%22b%22%3A2%7D&x-success=https%3A%2F%2Fchat.superhero.com&x-cancel=https%3A%2F%2Fchat.superhero.com')
.get('[data-cy=label]')
.eq(0)
.should('be.visible')
Expand Down
4 changes: 2 additions & 2 deletions tests/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
`&x-success=${encodeURIComponent(`${currentUrl}?result=success&signature={signature}`)}` +
`&x-cancel=${cancelUrl}`,
`sign-transaction?transaction=${encodedTx}&networkId=ae_mainnet&${callbackParams}`,
`jwt-sign?payload=%7B%22a%22%3A1%2C%22b%22%3A2%7D` +
`sign-jwt?payload=%7B%22a%22%3A1%2C%22b%22%3A2%7D` +
`&x-success=${encodeURIComponent(`${currentUrl}?result=success&signed-payload={signed-payload}`)}` +
`&x-cancel=${cancelUrl}`,
`jwt-sign?payload=%7B%22a%22%3A1%2C%22b%22%3A2%7D&x-success=https%3A%2F%2Fchat.superhero.com/{signed-payload}&x-cancel=https%3A%2F%2Fchat.superhero.com`,
`sign-jwt?payload=%7B%22a%22%3A1%2C%22b%22%3A2%7D&x-success=https%3A%2F%2Fchat.superhero.com/{signed-payload}&x-cancel=https%3A%2F%2Fchat.superhero.com`,
`invite/Yqk76XDXNGVMZiCVfzE9NGHwhbXiCAsah2bxVpevCGjdLeeqPaSBVR4CkAdLyb1a7HGn2RD69RDLxYF3rdL3MWouvTyyK`,
`invite#PZK6m94Sc5X2ibggH4sFPnG98GGdhCMzbpbHju4jSWxpoD4uB`,
];
Expand Down

0 comments on commit 04d94be

Please sign in to comment.