Skip to content

Commit

Permalink
Merge pull request #106 from Holo-Host/hbs-sign-payload
Browse files Browse the repository at this point in the history
Sign payloads for HBS Authentication
  • Loading branch information
Paterick authored Aug 29, 2023
2 parents cb11bcd + 4bef392 commit 00c3418
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Sign payload for HBS authentication

([#106]): https://github.com/Holo-Host/web-sdk/pull/106

## [0.6.13-prerelease] - 2023-07-26
### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@holo-host/web-sdk",
"version": "0.6.13-prerelease",
"version": "0.6.14-prerelease",
"description": "Standard development kit for creating Web UIs that work with Holo Hosting.",
"main": "dist/holo_hosting_web_sdk",
"module": "dist/holo_hosting_web_sdk.js",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ class WebSdkApi implements AppAgentClient {
disableCloneCell = (args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse> => this.#child.call('disableCloneCell', args).then(unwrap)

enableCloneCell = (args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse> => this.#child.call('enableCloneCell', args).then(unwrap)

signPayload = (args: any): Promise<any> => this.#child.call('signPayload', args).then(unwrap)

stateDump = () => this.#child.call('stateDump')

Expand Down
19 changes: 18 additions & 1 deletion tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('test API endpoints', () => {

beforeEach(async () => {
// Expected handshake response when successful is { happ_id, agent_state }
mock_comb.nextResponse({ happ_id: '', chaperone_state: { agent_state: {}, ui_state: {} }, chaperone_version: `0.1.0` })
mock_comb.nextResponse({ happ_id: '', chaperone_state: { agent_state: {}, ui_state: {} }, chaperone_version: `0.1.2` })
holo = await WebSdkApi.connect({
chaperoneUrl: ''
})
Expand Down Expand Up @@ -72,6 +72,23 @@ describe('test API endpoints', () => {

expect(response).toBeDefined()
expect(response).toMatchObject(expectedResponse)
})

it("should sign payloads", async () => {
const payload = { mockPayload: 'value' }
const expectedResponse = {
type: 'ok',
data: { signature: `signature`, signedPayload: `signedPayload`}
}

debugger
mock_comb.nextResponse(expectedResponse)

const response = await holo.signPayload(payload)

expect(response).toBeDefined()
expect(response).toHaveProperty('signature');
expect(response).toHaveProperty('signedPayload');
})
})

Expand Down

0 comments on commit 00c3418

Please sign in to comment.