Skip to content

Commit

Permalink
Merge pull request #2 from Holo-Host/add-api-description-04-16
Browse files Browse the repository at this point in the history
Add api description 04 16
  • Loading branch information
mrruby authored Apr 17, 2024
2 parents ba2af42 + e420197 commit 5ceea60
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion holo-key-manager-extension/src/lib/helpers/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const signMessage = async (message: string, index: number) => {
appKey.zero();

const validatedSchema = SuccessMessageSignedSchema.safeParse({
message: uint8ArrayToBase64(signedMessage)
signature: uint8ArrayToBase64(signedMessage)
});

if (!validatedSchema.success) {
Expand Down
2 changes: 1 addition & 1 deletion holo-key-manager-extension/static/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Holo key manager",
"description": "A browser extension to manage holo keys",
"version": "0.0.46",
"version": "0.0.47",
"manifest_version": 3,
"action": {
"default_title": "Holo key manager",
Expand Down
3 changes: 1 addition & 2 deletions holo-key-manager-js-client/.npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

node_modules/
/src/
types/
prebuild.cjs
index.ts
*.tgz
tsconfig.json
config.js

20 changes: 20 additions & 0 deletions holo-key-manager-js-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,23 @@ const getGenericErrorMessage = (error) => {
);
};
```

## API reference

```typescript
class HoloKeyManagerExtensionClient {
constructor({happId: string, happName: String, happLogo: Url, happUiUrl: Url, requireRegistrationCode: boolean, requireEmail:boolean})

async signIn(): Promise<pubKey: Uint8Array> {} // throws errors

async signUp(): Promise<{ email?: string, registration_code?: string, pubkey: Uint8Array }> {} // returns Promise of email and registration code if required in constructor, throws errors
async logOut() {} // throws errors

async signMessage(payload: Uint8Array): Promise<Uint8Array> {} // returns Promise of signature, throws errors

on('authorized', (Uint8Array, boolean) => void): UnsubscribeFunction {}
on('rejected', () => void): UnsubscribeFunction {}
}

type UnsubscribeFunction = () => void;
```
2 changes: 1 addition & 1 deletion holo-key-manager-js-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@holo-host/holo-key-manager-js-client",
"version": "0.0.2",
"version": "0.0.3",
"description": "A JavaScript client API for managing Holo keys",
"main": "lib/index.js",
"types": "lib/holo-key-manager-js-client/src/index.d.ts",
Expand Down
6 changes: 2 additions & 4 deletions holo-key-manager-js-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ const createHoloKeyManager = ({
sender: SENDER_WEBAPP
});

const { message } = parseMessagePayload<SuccessMessageSigned>(response, SIGN_MESSAGE_SUCCESS);
const { signature } = parseMessagePayload<SuccessMessageSigned>(response, SIGN_MESSAGE_SUCCESS);

return {
message: base64ToUint8Array(message)
};
return base64ToUint8Array(signature);
};

const performSignOutAction = async () => {
Expand Down
6 changes: 2 additions & 4 deletions holo-key-manager-js-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ type SignInSuccessPayload = {
pubKey: Uint8Array;
};

type SignMessageSuccessPayload = {
message: Uint8Array;
};
type SignMessageSuccessPayload = Uint8Array;

type RawPayload =
| { pubKey: string; email: string; registrationCode: string }
Expand All @@ -28,7 +26,7 @@ type RawPayload =
type IHoloKeyManager = {
signUp(): Promise<SignUpSuccessPayload>;
signIn(): Promise<SignInSuccessPayload>;
signMessage: (message: Uint8Array) => Promise<SignMessageSuccessPayload>;
signMessage: (message: Uint8Array) => Promise<Uint8Array>;
signOut(): Promise<void>;
};
export type {
Expand Down
6 changes: 4 additions & 2 deletions shared/types/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ const HappIdSchema = z.object({
});

export const SuccessMessageSignedSchema = z.object({
message: z.string()
signature: z.string()
});

export type SuccessMessageSigned = z.infer<typeof SuccessMessageSignedSchema>;

export const MessageToSignSchema = SuccessMessageSignedSchema.merge(HappIdSchema);
export const MessageToSignSchema = HappIdSchema.extend({
message: z.string()
});

export const PubKeySchema = z.object({
pubKey: z.string()
Expand Down

0 comments on commit 5ceea60

Please sign in to comment.