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

Create documentation and strong types, similar to signify-browser-extension #10

Closed
2byrds opened this issue May 23, 2024 · 4 comments
Closed

Comments

@2byrds
Copy link
Collaborator

2byrds commented May 23, 2024

@lenkan and others will use polaris-web without knowledge of the signify-browser-extension and currently that's where the interface and methods are documented.
Improve this repo to 'stand-alone' with documentation that guides and extension implementor to be to quickly understand the inputs/outputs.
Also consider a future issue to address versioning as we move forward (potentially create additional issues).

@lenkan
Copy link
Contributor

lenkan commented May 27, 2024

One additional thing that would be good to include is the error handling. How does the content script indicate to polaris-web that a particular request has failed?

@2byrds
Copy link
Collaborator Author

2byrds commented Aug 15, 2024

One additional thing that would be good to include is the error handling. How does the content script indicate to polaris-web that a particular request has failed?

@HunnySajid per @lenkan question can you respond here and let us know if this can be closed?

@lenkan
Copy link
Contributor

lenkan commented Aug 16, 2024

Regarding the error handling. There is now a mechanism for that, see for example this test here:

test("Should throw when responding with error", async () => {
const client = createClient();
const extension = createMockExtension();
handleMessage.mockImplementationOnce((ev) => {
extension.reject(ev, new Error("Declined"));
});
await expect(() =>
client.signData({
items: [randomBytes(10).toString("hex")],
}),
).rejects.toThrow("Declined");
});
and the reject "mock" implementation:
function reject(ev: MessageEvent, reason?: Error) {
postMessage({
type,
requestId: ev.data.requestId,
error: reason?.message ?? "Something went wrong",
});
}

In other words, if you add a "error" property to the response message, it will be treated as an error.

@lenkan
Copy link
Contributor

lenkan commented Aug 16, 2024

Also, the example app provides sufficient standalone documentation in my opinion.

@2byrds 2byrds closed this as completed Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants