Skip to content

Commit

Permalink
fix: add readme in main package and improve examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
elribonazo committed Jan 19, 2024
1 parent a9e5be4 commit 91b02e5
Show file tree
Hide file tree
Showing 9 changed files with 315 additions and 203 deletions.
78 changes: 77 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,83 @@
# Pluto Encrypted
Is a community maintained project which aims to bring a scalable and future proof storage solution for Wallet SDK on typescript. By using this package you can ensure that this dependency will fit the AtalaPrism wallet SDK contract and provide the SDK with storage finally.

This package is compatible with Atala Prism Wallet SDK v3.2.0
## Interface
Edge SDK Pluto interface [v4.0.0-rc1](https://input-output-hk.github.io/atala-prism-wallet-sdk-ts/interfaces/Domain.Pluto.html)
```typescript

export interface Pluto {

storeCredentialMetadata(metadata: Anoncreds.CredentialRequestMeta, linkSecret: Anoncreds.LinkSecret): Promise<void>;

fetchCredentialMetadata(linkSecretName: string): Promise<Anoncreds.CredentialRequestMeta | null>;

start(): Promise<void>;

storePrismDID(did: DID, keyPathIndex: number, privateKey: PrivateKey, privateKeyMetaId: string | null, alias?: string): Promise<void>;

storePeerDID(did: DID, privateKeys: Array<PrivateKey>): Promise<void>;

storeDIDPair(host: DID, receiver: DID, name: string): Promise<void>;

storeMessage(message: Message): Promise<void>;

storeMessages(messages: Array<Message>): Promise<void>;

storePrivateKeys(privateKey: PrivateKey, did: DID, keyPathIndex: number, metaId: string | null): Promise<void>;

storeMediator(mediator: DID, host: DID, routing: DID): Promise<void>;

storeCredential(credential: Credential): Promise<void>;

getAllPrismDIDs(): Promise<PrismDIDInfo[]>;

getDIDInfoByDID(did: DID): Promise<PrismDIDInfo | null>;

getDIDInfoByAlias(alias: string): Promise<PrismDIDInfo[]>;

getPrismDIDKeyPathIndex(did: DID): Promise<number | null>;

getPrismLastKeyPathIndex(): Promise<number>;

getAllPeerDIDs(): Promise<Array<PeerDID>>;

getDIDPrivateKeysByDID(did: DID): Promise<Array<PrivateKey>>;

getDIDPrivateKeyByID(id: string): Promise<PrivateKey | null>;

getAllDidPairs(): Promise<Array<DIDPair>>;

getPairByDID(did: DID): Promise<DIDPair | null>;

getPairByName(name: string): Promise<DIDPair | null>;

getAllMessages(): Promise<Array<Message>>;

getAllMessagesByDID(did: DID): Promise<Array<Message>>;

getAllMessagesSent(): Promise<Array<Message>>;

getAllMessagesReceived(): Promise<Array<Message>>;

getAllMessagesSentTo(did: DID): Promise<Array<Message>>;

getAllMessagesReceivedFrom(did: DID): Promise<Array<Message>>;

getAllMessagesOfType(type: string, relatedWithDID?: DID): Promise<Array<Message>>;

getAllMessagesByFromToDID(from: DID, to: DID): Promise<Array<Message>>;

getMessage(id: string): Promise<Message | null>;

getAllMediators(): Promise<Array<Mediator>>;

getAllCredentials(): Promise<Array<Credential>>;

getLinkSecret(linkSecretName?: string): Promise<Anoncreds.LinkSecret | null>;

storeLinkSecret(linkSecret: Anoncreds.LinkSecret, linkSecretName: string): Promise<void>;
}
```

We currently support database wrappers for IndexDB, InMemory and are working together to bring you level-db with electron compatibility.
We are not going to stop here but ensure that our SDK can be used in any platform and language.
Expand Down
46 changes: 2 additions & 44 deletions examples/browser/craco.config.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,12 @@
const CopyPlugin = require("copy-webpack-plugin");
const path = require("path");

module.exports = {
webpack: {
configure: (webpackConfig) => {
const moduleScopePlugin = webpackConfig.resolve.plugins.find(({ constructor }) => constructor?.name === "ModuleScopePlugin");
const demosPath = path.resolve(__dirname, "../");
moduleScopePlugin.appSrcs = [demosPath];
const oneOfRule = webpackConfig.module.rules.find(x => x.oneOf);
const tsxRule = oneOfRule.oneOf.find(x => x.test && x.test.toString().includes("tsx"));
const plutoPath = `${demosPath}/pluto/`;
tsxRule.include = [tsxRule.include, plutoPath];

// Force browser entry
webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
'@atala/prism-wallet-sdk': path.resolve(
__dirname,
'node_modules/@atala/prism-wallet-sdk/build/browser/index.js'
),
}
// Wasms - copy to public
webpackConfig.resolve.extensions.push(".wasm");
webpackConfig.plugins = [
new CopyPlugin({
patterns: [
{
force: true,
from: path.resolve(
__dirname,
"node_modules/@atala/prism-wallet-sdk/build/browser/*.wasm"
),
// Define the destination directory within the project
to: path.resolve(__dirname, "public"),
},
],
}),
...(webpackConfig.plugins || []),
];

webpackConfig.resolve.fallback = {
fs: false,
crypto: false,
// assert: require.resolve("assert/"),
// url: require.resolve("url/"),
// buffer: require.resolve("buffer/"),
stream: require.resolve("stream-browserify"),
path: require.resolve("path-browserify"),
stream: false,
path: false,
};

return webpackConfig;
},
},
Expand Down
115 changes: 67 additions & 48 deletions examples/browser/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@atala/prism-wallet-sdk": "^3.2.0",
"@pluto-encrypted/database": "^1.2.3",
"@pluto-encrypted/indexdb": "^1.3.1",
"@atala/prism-wallet-sdk": "^4.0.0-rc.1",
"@pluto-encrypted/database": "^1.15.1",
"@pluto-encrypted/indexdb": "^1.12.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand All @@ -24,8 +24,6 @@
"web-vitals": "^2.1.4"
},
"scripts": {
"postinstall": "npm run copy-wasm",
"copy-wasm": "cp node_modules/@atala/prism-wallet-sdk/build/browser/*.wasm public",
"start": "craco start",
"build": "craco build",
"test": "craco test"
Expand Down
Loading

0 comments on commit 91b02e5

Please sign in to comment.