diff --git a/holo-key-manager-extension/src/lib/helpers/queries.ts b/holo-key-manager-extension/src/lib/helpers/queries.ts index c4b7eb0..5855abc 100644 --- a/holo-key-manager-extension/src/lib/helpers/queries.ts +++ b/holo-key-manager-extension/src/lib/helpers/queries.ts @@ -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) { diff --git a/holo-key-manager-extension/static/manifest.json b/holo-key-manager-extension/static/manifest.json index fd7ab35..1911870 100644 --- a/holo-key-manager-extension/static/manifest.json +++ b/holo-key-manager-extension/static/manifest.json @@ -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", diff --git a/holo-key-manager-js-client/.npmignore b/holo-key-manager-js-client/.npmignore index 9189609..a31c7d0 100644 --- a/holo-key-manager-js-client/.npmignore +++ b/holo-key-manager-js-client/.npmignore @@ -1,9 +1,8 @@ node_modules/ /src/ -types/ -prebuild.cjs index.ts *.tgz tsconfig.json +config.js diff --git a/holo-key-manager-js-client/README.md b/holo-key-manager-js-client/README.md index 3ee7a26..d3c3a57 100644 --- a/holo-key-manager-js-client/README.md +++ b/holo-key-manager-js-client/README.md @@ -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 {} // 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 {} // returns Promise of signature, throws errors + + on('authorized', (Uint8Array, boolean) => void): UnsubscribeFunction {} + on('rejected', () => void): UnsubscribeFunction {} +} + +type UnsubscribeFunction = () => void; +``` diff --git a/holo-key-manager-js-client/package.json b/holo-key-manager-js-client/package.json index 7a7de15..3290fbb 100644 --- a/holo-key-manager-js-client/package.json +++ b/holo-key-manager-js-client/package.json @@ -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", diff --git a/holo-key-manager-js-client/src/index.ts b/holo-key-manager-js-client/src/index.ts index 67c7bf8..c134820 100644 --- a/holo-key-manager-js-client/src/index.ts +++ b/holo-key-manager-js-client/src/index.ts @@ -82,11 +82,9 @@ const createHoloKeyManager = ({ sender: SENDER_WEBAPP }); - const { message } = parseMessagePayload(response, SIGN_MESSAGE_SUCCESS); + const { signature } = parseMessagePayload(response, SIGN_MESSAGE_SUCCESS); - return { - message: base64ToUint8Array(message) - }; + return base64ToUint8Array(signature); }; const performSignOutAction = async () => { diff --git a/holo-key-manager-js-client/src/types.ts b/holo-key-manager-js-client/src/types.ts index c59a002..feb02ca 100644 --- a/holo-key-manager-js-client/src/types.ts +++ b/holo-key-manager-js-client/src/types.ts @@ -16,9 +16,7 @@ type SignInSuccessPayload = { pubKey: Uint8Array; }; -type SignMessageSuccessPayload = { - message: Uint8Array; -}; +type SignMessageSuccessPayload = Uint8Array; type RawPayload = | { pubKey: string; email: string; registrationCode: string } @@ -28,7 +26,7 @@ type RawPayload = type IHoloKeyManager = { signUp(): Promise; signIn(): Promise; - signMessage: (message: Uint8Array) => Promise; + signMessage: (message: Uint8Array) => Promise; signOut(): Promise; }; export type { diff --git a/shared/types/message.ts b/shared/types/message.ts index d0723e0..e8b9556 100644 --- a/shared/types/message.ts +++ b/shared/types/message.ts @@ -26,12 +26,14 @@ const HappIdSchema = z.object({ }); export const SuccessMessageSignedSchema = z.object({ - message: z.string() + signature: z.string() }); export type SuccessMessageSigned = z.infer; -export const MessageToSignSchema = SuccessMessageSignedSchema.merge(HappIdSchema); +export const MessageToSignSchema = HappIdSchema.extend({ + message: z.string() +}); export const PubKeySchema = z.object({ pubKey: z.string()