Skip to content

Commit

Permalink
Merge pull request #160 from HunnySajid/docs/signature-type
Browse files Browse the repository at this point in the history
Docs/signature type
  • Loading branch information
2byrds authored Apr 8, 2024
2 parents 3a0b726 + 4ba07a5 commit d6aafce
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
10 changes: 7 additions & 3 deletions GETTING_STARTED_WEB_CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
```

### Usage
import following methods from `polaris-web`
import following methods from `signify-polaris-web`

```
import {
Expand All @@ -22,14 +22,14 @@ import {
requestCredential, // call to select credential for signing in
requestAidORCred, // call to select either aid of credential
requestAutoSignin, // call for auto signin
} from "polaris-web";
} from "signify-polaris-web";
```

### Usage subscribeToSignature
`subscribeToSignature` is a mandatory subscription call that receives a function to return signature, e.g:
```
const handleSignifyData = (data) => {
const handleSignifyData = (data: ISignature) => {
console.log("signature", data);
};
Expand All @@ -41,6 +41,10 @@ useEffect(() => {
}, []);
```

#### [ISignature](./src/config/types.ts) data type
The callback from **subscribeToSignature** receives signature that contains header and credential(optional)


### Usage unsubscribeFromSignature
`unsubscribeFromSignature` to unsubscription e.g:
```
Expand Down
21 changes: 5 additions & 16 deletions src/components/credentialCard.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
import { useIntl } from "react-intl";
import { ICredential } from "@config/types";
import { Text, Subtext, Card, Flex, Box } from "@components/ui";
import CredentialIcon from "@components/shared/icons/credential";
import ValidIcon from "@components/shared/icons/valid";
import RevokedIcon from "@components/shared/icons/revoked";

interface ICredential {
issueeName: string;
schema: {
title: string;
credentialType: string;
description: string;
};
status: {
et: string;
};
}

interface ICredentialCard {
export function CredentialCard({
credential,
}: {
credential: ICredential;
}

export function CredentialCard({ credential }: ICredentialCard): JSX.Element {
}): JSX.Element {
const { formatMessage } = useIntl();

return (
Expand Down
19 changes: 10 additions & 9 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export interface IHandler {
tabId?: number;
url?: string;
data?: any;

}
export interface IMessage<T> {
type: string;
Expand Down Expand Up @@ -47,13 +46,7 @@ export interface ISignin {
name?: string;
prefix?: string;
};
credential?: {
issueeName?: string;
sad: { d: string };
schema?: {
title: string;
};
};
credential?: ICredential;
createdAt: number;
updatedAt: number;
autoSignin?: boolean;
Expand All @@ -66,7 +59,8 @@ export interface IIdentifier {

export interface ICredential {
issueeName: string;
sad: { a: { i: string }, d: string };
ancatc: string[];
sad: { a: { i: string }; d: string };
schema: {
title: string;
credentialType: string;
Expand All @@ -76,3 +70,10 @@ export interface ICredential {
et: string;
};
}

export interface ISignature {
headers: {
[key: string]: string;
};
credential?: ICredential;
}
14 changes: 10 additions & 4 deletions src/pages/background/services/signify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { userService } from "@pages/background/services/user";
import { configService } from "@pages/background/services/config";
import { removeSlash } from "@pages/background/utils";
import { IIdentifier, ISignin } from "@config/types";
import { IIdentifier, ISignin, ISignature } from "@config/types";

const PASSCODE_TIMEOUT = 5;

Expand Down Expand Up @@ -169,7 +169,13 @@ const Signify = () => {
return signed_headers;
};

const getSignedHeaders = async ({ url, signin } : { url: string, signin: ISignin }) => {
const getSignedHeaders = async ({
url,
signin,
}: {
url: string;
signin: ISignin;
}): Promise<ISignature> => {
const origin = removeSlash(url!);
const signedHeaders = await signHeaders(
signin.identifier
Expand All @@ -184,7 +190,7 @@ const Signify = () => {

return {
headers: jsonHeaders,
credential: signin?.credential ?? null,
credential: signin?.credential,
};
};

Expand All @@ -210,7 +216,7 @@ const Signify = () => {
generatePasscode,
bootAndConnect,
getControllerID,
getSignedHeaders
getSignedHeaders,
};
};

Expand Down

0 comments on commit d6aafce

Please sign in to comment.