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

Add: Update GoodID and claim flow #128

Open
wants to merge 180 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
6306783
add: goodid credentials db and veramo types
L03TJ3 Feb 21, 2024
395fc47
add goodid context and (wip) credentials hook
L03TJ3 Feb 21, 2024
e514376
add: story example for goodid
L03TJ3 Feb 21, 2024
eaec88e
fix: veramo types for next packages
L03TJ3 Feb 21, 2024
3713ae5
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Feb 23, 2024
2b492fa
fix: use outbound key as primary
L03TJ3 Feb 27, 2024
7c03881
use updated expected credential schema types
L03TJ3 Feb 27, 2024
681a6dd
use put instead of add for creating credential
L03TJ3 Mar 5, 2024
eeebaa0
add: deleteCredential
L03TJ3 Mar 5, 2024
4939576
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Mar 10, 2024
f050787
update context with react prop types
L03TJ3 Mar 10, 2024
05beb0f
remove no longer needed test resolver
L03TJ3 Mar 10, 2024
6b2e78e
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Mar 12, 2024
0d1bb39
define new db schema using certificates definition
L03TJ3 Mar 12, 2024
38dfe5a
- update to certificates hook to match naming/db schema
L03TJ3 Mar 12, 2024
3922e30
Update GoodId context to new hook/types
L03TJ3 Mar 12, 2024
7193179
update goodid story, yarn lock
L03TJ3 Mar 12, 2024
8b322ef
remove veramo deps and references
L03TJ3 Mar 12, 2024
3c97722
add: use simple certificates table collection
L03TJ3 Mar 12, 2024
c752b38
update certificate schema / use of multiEntryIndex
L03TJ3 Mar 12, 2024
5f9925c
wip: apply suggested changes
L03TJ3 Mar 14, 2024
5265c8a
Revert "wip: apply suggested changes"
L03TJ3 Mar 15, 2024
23e64cd
apply exact solution
L03TJ3 Mar 15, 2024
397fabc
remove not used story
L03TJ3 Mar 15, 2024
51d034d
Update packages/sdk-v2/src/sdk/goodid/hooks/useCertificates.ts
johnsmith-gooddollar Mar 15, 2024
bddc880
Update packages/sdk-v2/src/sdk/goodid/db/createDb.ts
johnsmith-gooddollar Mar 15, 2024
6fc954a
add missing schema update after revert
L03TJ3 Mar 15, 2024
7c53df7
Create CertificatesExample.stories.tsx
johnsmith-gooddollar Mar 15, 2024
26e1ea0
Merge branch '116-credential-storage' of github.com:GoodDollar/GoodWe…
L03TJ3 Mar 15, 2024
a4e4869
Update packages/sdk-v2/src/sdk/goodid/hooks/useCertificates.ts
johnsmith-gooddollar Mar 15, 2024
d4c5fa0
Update packages/sdk-v2/src/stories/goodid/CertificatesExample.stories…
johnsmith-gooddollar Mar 15, 2024
cd6a12e
final implementation, updated storybook
johnsmith-gooddollar Mar 15, 2024
db41581
Merge branch '116-credential-storage' of github.com:GoodDollar/GoodWe…
L03TJ3 Mar 20, 2024
f9969ad
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Mar 20, 2024
4071a47
fix: types and story delete flow
L03TJ3 Mar 20, 2024
c241aee
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Mar 20, 2024
bc0b729
116 goodid card (#129)
L03TJ3 Mar 20, 2024
833572e
remove unused deps/resolutions
L03TJ3 Mar 21, 2024
83d1935
apply pr suggestions
L03TJ3 Mar 21, 2024
c65ed8e
Apply suggestions from code review
johnsmith-gooddollar Mar 22, 2024
c113083
fix: lock
L03TJ3 Mar 26, 2024
072faa2
chore: align ctix quote with eslint
L03TJ3 Mar 26, 2024
e92d61e
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Mar 26, 2024
a0d1b07
fix: goodid card labels
L03TJ3 Mar 26, 2024
81e9236
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Mar 28, 2024
ef3d45e
add show all types in useAggregatedCertificates
johnsmith-gooddollar Mar 29, 2024
86a8cee
fix: yarn lock
L03TJ3 Apr 2, 2024
ce8aac6
fix: yarn.lock
L03TJ3 Apr 2, 2024
71f4835
type fix
L03TJ3 Apr 2, 2024
054ca0b
115 onboard screen (#130)
L03TJ3 Apr 2, 2024
ad7d86e
fix: type
L03TJ3 Apr 3, 2024
239667e
wip: aggregated certificates hook for goodid card
L03TJ3 Apr 3, 2024
095a36f
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Apr 8, 2024
fa333cf
fix: sdk-v2 self dependency
L03TJ3 Apr 10, 2024
7631248
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Apr 10, 2024
d7a00e6
fix: lock
L03TJ3 Apr 10, 2024
efea670
Dev version beta.d7a00e6 released
L03TJ3 Apr 10, 2024
12a766c
trigger vercel deployment
L03TJ3 Apr 10, 2024
dbe713b
wip: test sdk-v2 build:release for beta package
L03TJ3 Apr 10, 2024
a5fd111
Dev version beta.dbe713b released
L03TJ3 Apr 10, 2024
dd8ebb5
trigger vercel deployment
L03TJ3 Apr 11, 2024
3a778e2
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Apr 15, 2024
9c05cd6
[GoodID] 122 Redtent Offer (#141)
sirpy Apr 15, 2024
efda7af
fix: lock
L03TJ3 Apr 15, 2024
fc9ba26
Dev version beta.efda7af released
L03TJ3 Apr 15, 2024
1264168
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Apr 17, 2024
813b5f1
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Apr 18, 2024
5ff8bdb
fix: yarn.lock
L03TJ3 Apr 18, 2024
349c906
122: redtent UI (#148)
L03TJ3 Apr 25, 2024
2c55f4c
fix: yarnlock
L03TJ3 Apr 25, 2024
c3f844b
Dev version beta.2c55f4c released
L03TJ3 Apr 25, 2024
5730cb5
117 segmentation (#136)
L03TJ3 Apr 29, 2024
c7ba600
fix: circular deps, fix: exports for good-id components
L03TJ3 May 6, 2024
f8f20a4
Dev version beta.c7ba600 released
L03TJ3 May 6, 2024
c4682c7
fix: broken sdk-v2 dev release, revert to previous
L03TJ3 May 6, 2024
46e3b1e
152 segmentation dispute (#154)
L03TJ3 May 17, 2024
245950a
124 check available offers (#158)
L03TJ3 May 17, 2024
201d7d7
155 onboard changes (#167)
L03TJ3 Jun 10, 2024
04a2c90
Dev version beta.201d7d7 released
L03TJ3 Jun 10, 2024
2a595b9
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Jun 25, 2024
954e157
fix: verify unique modal (dapp)
L03TJ3 Jun 26, 2024
83c0986
Dev version beta.954e157 released
L03TJ3 Jun 26, 2024
916d09c
145: goodid details (#169)
L03TJ3 Jul 2, 2024
36c2495
159 redtent video modals (#170)
L03TJ3 Jul 2, 2024
55a9746
Dev version beta.36c24955 released
L03TJ3 Jul 2, 2024
f0fc9a1
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Jul 16, 2024
ba2fadc
Dev version beta.f0fc9a19 released
L03TJ3 Jul 16, 2024
ba70dfa
fix: handle partial success when requesting certificates
L03TJ3 Jul 16, 2024
e183c80
Dev version beta.ba70dfad released
L03TJ3 Jul 16, 2024
c5783e2
add configurable env to segmentation flow story
L03TJ3 Jul 17, 2024
6889de2
Dev version beta.c5783e2f released
L03TJ3 Jul 17, 2024
329d88b
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Jul 17, 2024
c1a238f
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Jul 17, 2024
8e467cd
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Aug 6, 2024
75b0cce
Dev version beta.8e467cd1 released
L03TJ3 Aug 6, 2024
80712d0
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Aug 12, 2024
dd05238
Dev version beta.80712d00 released
L03TJ3 Aug 12, 2024
5779254
add: pool criteria for dev-env flow
L03TJ3 Aug 20, 2024
a82516e
Dev version beta.5779254c released
L03TJ3 Aug 20, 2024
957e3e0
168 gooddesign localization (#171)
L03TJ3 Aug 26, 2024
fa7b854
Merge branch 'master' into 116-credential-storage
sirpy Sep 4, 2024
16b891c
fix: extract certificates
sirpy Sep 4, 2024
0b9bebc
add: bump versions
sirpy Sep 4, 2024
4bd6bec
Fixes:
L03TJ3 Sep 6, 2024
e637626
fix: use data-permission
L03TJ3 Sep 6, 2024
abb32d9
Dev version beta.e637626f released
L03TJ3 Sep 6, 2024
62e07ae
fix: redtentthanks next button
L03TJ3 Sep 6, 2024
fa18582
Dev version beta.62e07aeb released
L03TJ3 Sep 6, 2024
3cd8d0f
[Goodid] add new claim flow (#162)
L03TJ3 Sep 18, 2024
f604325
Dev version beta.3cd8d0fc released
L03TJ3 Sep 18, 2024
c5b1daf
fix: navigation, img, copy
L03TJ3 Sep 19, 2024
c81c523
Dev version beta.c5b1dafc released
L03TJ3 Sep 19, 2024
6e632f1
fix: disputeValues should refresh
L03TJ3 Sep 20, 2024
bfa74e5
Dev version beta.6e632f16 released
L03TJ3 Sep 20, 2024
7b8a2c2
bump goodcollective-sdk
L03TJ3 Sep 20, 2024
b7ddd6f
Dev version beta.7b8a2c20 released
L03TJ3 Sep 20, 2024
9fb694c
fix: document not defined on android
L03TJ3 Sep 20, 2024
57c1029
Dev version beta.9fb694c7 released
L03TJ3 Sep 20, 2024
ac2b3a4
wip: goodid fixes for android
L03TJ3 Sep 21, 2024
1fdee33
Dev version beta.ac2b3a4d released
L03TJ3 Sep 21, 2024
b6b260b
Fixes include:
L03TJ3 Sep 24, 2024
603d9eb
Dev version beta.b6b260b1 released
L03TJ3 Sep 24, 2024
4ea5e45
fix:
L03TJ3 Sep 25, 2024
0e451dc
Dev version beta.4ea5e456 released
L03TJ3 Sep 25, 2024
49c2374
wip: fixes for android support
L03TJ3 Sep 25, 2024
c67e7f2
Dev version beta.49c23743 released
L03TJ3 Sep 25, 2024
9d904e3
fix: failed-fv would not return to face-verification screen next time
L03TJ3 Sep 25, 2024
8601384
Dev version beta.9d904e3e released
L03TJ3 Sep 25, 2024
2276411
hotfix-merge: flow-fixes
L03TJ3 Sep 25, 2024
7f5594e
Merge branch '116-credential-storage' of github.com:GoodDollar/GoodWe…
L03TJ3 Sep 25, 2024
5a76e06
Dev version beta.7f5594ed released
L03TJ3 Sep 25, 2024
81fd194
fix: video upload onError flow
L03TJ3 Sep 30, 2024
23e3f37
chore:lingui
L03TJ3 Sep 30, 2024
6be4b57
Dev version beta.23e3f37e released
L03TJ3 Sep 30, 2024
d33b053
fixes include:
L03TJ3 Oct 2, 2024
9e36268
Dev version beta.d33b0532 released
L03TJ3 Oct 2, 2024
f927508
fix: claim-flow with local nav bar, chore style fixes
L03TJ3 Oct 3, 2024
96091f1
Dev version beta.f9275089 released
L03TJ3 Oct 3, 2024
a2b0641
fix: redtent offer styling and shown values
L03TJ3 Oct 4, 2024
de52836
chore: lingui
L03TJ3 Oct 4, 2024
a841f10
chore: lingui
L03TJ3 Oct 4, 2024
df61635
Dev version beta.a841f10d released
L03TJ3 Oct 4, 2024
4fedc7c
chore: lingui
L03TJ3 Oct 4, 2024
1f4f6b8
Dev version beta.4fedc7cd released
L03TJ3 Oct 4, 2024
1985097
fix: also export lastAuthenticated from identity hook
L03TJ3 Oct 7, 2024
2319fac
Dev version beta.1985097e released
L03TJ3 Oct 7, 2024
d00dd87
fix: file-extension for video-upload might be uppercase
L03TJ3 Oct 7, 2024
4359bf7
fix: recent claims list long loading blocking post-claim screen
L03TJ3 Oct 7, 2024
57b3853
fix: wrong icon showing, wip-fix: small delay for showing segmentatio…
L03TJ3 Oct 7, 2024
2b4699b
Dev version beta.57b38532 released
L03TJ3 Oct 7, 2024
085355e
chore: copy update
L03TJ3 Oct 8, 2024
64fceb7
fix: scrollable list on android
L03TJ3 Oct 8, 2024
e289c69
Dev version beta.64fceb78 released
L03TJ3 Oct 8, 2024
4297c67
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Oct 15, 2024
844d8ce
fix: should use source for images on android
L03TJ3 Oct 15, 2024
152159e
Dev version beta.844d8ce1 released
L03TJ3 Oct 16, 2024
c5e9b1f
fix: faucet refresh after tx
sirpy Oct 22, 2024
c22a5b9
fix: use production env when on production
L03TJ3 Oct 22, 2024
4803d2b
chore: lingui
L03TJ3 Oct 22, 2024
d4ddc54
use default language if non-supported is used
L03TJ3 Oct 22, 2024
005e91b
Dev version beta.d4ddc54b released
L03TJ3 Oct 22, 2024
49b9ce0
Goodid out of gas (#205)
L03TJ3 Oct 24, 2024
86e77e1
fix: video upload on android
L03TJ3 Oct 25, 2024
f993e4c
fix: redtent offer flow style fixes
L03TJ3 Oct 25, 2024
91555be
Dev version beta.f993e4cd released
L03TJ3 Oct 25, 2024
df1e8f0
fix: pool contracts not loading on staging/production
L03TJ3 Oct 28, 2024
a3a39d2
New Crowdin updates (#202)
L03TJ3 Oct 28, 2024
ec58ee2
Merge branch '116-credential-storage' of github.com:GoodDollar/GoodWe…
L03TJ3 Oct 28, 2024
899dd95
Dev version beta.ec58ee2a released
L03TJ3 Oct 28, 2024
d8ba27b
fixes -->
L03TJ3 Oct 28, 2024
0e703b2
New Crowdin updates (#207)
L03TJ3 Oct 28, 2024
460739e
Merge branch '116-credential-storage' of github.com:GoodDollar/GoodWe…
L03TJ3 Oct 28, 2024
f2e0636
chore: lingui
L03TJ3 Oct 28, 2024
783b394
Dev version beta.f2e0636f released
L03TJ3 Oct 28, 2024
db91ac2
fix: typo
L03TJ3 Oct 29, 2024
03a153f
Merge branch 'master' of github.com:GoodDollar/GoodWeb3-Mono into 116…
L03TJ3 Nov 2, 2024
6bdc3f9
chore: bump gc-sdk to latest
L03TJ3 Nov 2, 2024
fb2fd61
Dev version beta.6bdc3f93 released
L03TJ3 Nov 2, 2024
47071d6
fix: styleprop should be number
L03TJ3 Nov 20, 2024
ee46d53
Dev version beta.47071d6a released
L03TJ3 Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@
"pinst": "^3.0.0",
"prettier": "2.8.8",
"typescript": "^4.9.3"
},
"resolutions": {
"@veramo/core-types": "5.6.1-next.45+d5375bd03"
L03TJ3 marked this conversation as resolved.
Show resolved Hide resolved
}
}
10 changes: 9 additions & 1 deletion packages/sdk-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"@types/node": "18.0.0",
"@types/react-native": "0.70.4",
"@usedapp/core": "^1.2.13",
"@veramo/core-types": "5.6.1-next.45",
johnsmith-gooddollar marked this conversation as resolved.
Show resolved Hide resolved
"@veramo/did-provider-ethr": "^5.6.1-next.45",
"@veramo/did-provider-key": "^5.6.1-next.45",
"babel-jest": "^27.3.1",
"babel-loader": "^8.2.3",
"babel-plugin-module-resolver": "^4.1.0",
Expand All @@ -51,7 +54,9 @@
"css-loader": "^6.5.1",
"ctix": "^1.4.0",
"dexie-react-hooks": "^1.1.6",
"did-resolver": "^4.1.0",
L03TJ3 marked this conversation as resolved.
Show resolved Hide resolved
"ethers": "5.7.2",
"ethr-did-resolver": "^10.1.5",
johnsmith-gooddollar marked this conversation as resolved.
Show resolved Hide resolved
"html-webpack-plugin": "^5.5.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.3.1",
Expand All @@ -67,7 +72,8 @@
"style-loader": "^3.3.1",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^5.2.2",
"uuid": "^9.0.1"
"uuid": "^9.0.1",
"web-did-resolver": "^2.0.27"
johnsmith-gooddollar marked this conversation as resolved.
Show resolved Hide resolved
},
"dependencies": {
"@amplitude/analytics-browser": "^1.6.4",
Expand All @@ -83,6 +89,8 @@
"@sentry/react-native": "^5.15.1",
"@solana/web3.js": "^1.72.0",
"@types/react": "^18.2.28",
"@veramo-community/veramo-react": "^1.6.7",
"@veramo/did-resolver": "next",
"@walletconnect/client": "^1.8.0",
"@walletconnect/qrcode-modal": "^1.8.0",
"@web3-onboard/coinbase": "^2.2.6",
Expand Down
37 changes: 37 additions & 0 deletions packages/sdk-v2/src/contexts/goodid/GoodIdContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { createContext } from "react";

import type { VerifiableCredential } from "../../sdk/goodid/types";
import { createCredentialsDb, useCredentials } from "../../sdk/goodid";

type IGoodIdContext = {
createCredential?: (credential: VerifiableCredential) => Promise<void>;
getActiveCredentials?: () => Promise<VerifiableCredential[] | undefined>;
db: any;
};

export const GoodIdContext = createContext<IGoodIdContext>({
db: undefined
});

interface IGoodIdContextProvider {
L03TJ3 marked this conversation as resolved.
Show resolved Hide resolved
children: any;
L03TJ3 marked this conversation as resolved.
Show resolved Hide resolved
localDb?: any; //todo: define db interface for wallet
}

export const GoodIdContextProvider = ({ children, localDb }: IGoodIdContextProvider) => {
L03TJ3 marked this conversation as resolved.
Show resolved Hide resolved
const db = localDb ? new localDb() : createCredentialsDb();

const { createCredential, getActiveCredentials } = useCredentials(db);

return (
<GoodIdContext.Provider
johnsmith-gooddollar marked this conversation as resolved.
Show resolved Hide resolved
value={{
createCredential,
getActiveCredentials,
db
}}
>
{children}
</GoodIdContext.Provider>
);
};
1 change: 1 addition & 0 deletions packages/sdk-v2/src/contexts/goodid/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./GoodIdContext";
7 changes: 4 additions & 3 deletions packages/sdk-v2/src/contexts/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './newsfeed';
export * from './Web3Context';
export * from './web3modal';
export * from "./goodid";
export * from "./newsfeed";
export * from "./Web3Context";
export * from "./web3modal";
17 changes: 17 additions & 0 deletions packages/sdk-v2/src/sdk/goodid/db/createDb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Dexie from "dexie";

/**
* Schema definition for the credentials collection
* - `type`: should indicate the type of the credential
* - Other fields are according to Veramo's Credential schema
*/

const schema = {
credentials: ",type, credentialSubject.id, issuer.id, issuanceDate"
johnsmith-gooddollar marked this conversation as resolved.
Show resolved Hide resolved
};

export const createCredentialsDb = () => {
const db = new Dexie("GoodIdCredentials", { autoOpen: false });
db.version(1).stores(schema);
return db;
};
1 change: 1 addition & 0 deletions packages/sdk-v2/src/sdk/goodid/db/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./createDb";
1 change: 1 addition & 0 deletions packages/sdk-v2/src/sdk/goodid/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./useCredentials";
34 changes: 34 additions & 0 deletions packages/sdk-v2/src/sdk/goodid/hooks/useCredentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useCallback } from "react";
import type { VerifiableCredential } from "../types";

// todo: create credential should consider update if already exists
// todo: add db updateCredential
// todo: add db deleteCredential

export const useCredentials = (db: any) => {
const getActiveCredentials: () => Promise<VerifiableCredential[] | undefined> = useCallback(async () => {
try {
await db.open();
const credentialsList = (await db.credentials.toArray()) as VerifiableCredential[];
console.log("credentialsList -->", { credentialsList });
return credentialsList;
} catch (error) {
console.error("Failed to get active credentials:", error);
} finally {
await db.close();
}
}, [db]);

const createCredential = async (credential: VerifiableCredential) => {
johnsmith-gooddollar marked this conversation as resolved.
Show resolved Hide resolved
try {
await db.open();
await db.credentials.add(credential, [credential.type[1]]);
} catch (error) {
console.error("Failed to create credential:", error);
} finally {
await db.close();
}
};

return { getActiveCredentials, createCredential };
};
3 changes: 3 additions & 0 deletions packages/sdk-v2/src/sdk/goodid/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./db";
export * from "./hooks";
export * from "./types";
30 changes: 30 additions & 0 deletions packages/sdk-v2/src/sdk/goodid/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Reference: https://veramo.io/docs/basics/verifiable_data
export interface CredentialProof {
type: string;
jwt: string;
}

export interface CredentialSubject {
id: string;
[key: string]: any;
}

export interface Issuer {
id: string;
}

export interface VerifiableCredential {
L03TJ3 marked this conversation as resolved.
Show resolved Hide resolved
credentialSubject: CredentialSubject;
issuer: Issuer;
type: string[];
"@context": string[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont believe that's the right type for @context

issuanceDate: string;
proof: CredentialProof;
}

// Might change
export enum CredentialTypes {
johnsmith-gooddollar marked this conversation as resolved.
Show resolved Hide resolved
VerifiableAgeCredential = "Age",
VerifiableGenderCredential = "Gender",
VerifiableLocationCredential = "Location"
}
33 changes: 33 additions & 0 deletions packages/sdk-v2/src/sdk/goodid/utils/resolverAgent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// import { createAgent, IResolver } from "@veramo/core";
L03TJ3 marked this conversation as resolved.
Show resolved Hide resolved

// import { DIDResolverPlugin } from "@veramo/did-resolver";
// import { Resolver } from "did-resolver";
// import { getResolver as ethrDidResolver } from "ethr-did-resolver";
// import { getResolver as webDidResolver } from "web-did-resolver";

// const INFURA_PROJECT_ID = "9411575f49c84289a51a7dab811049cb";

// export const agent = createAgent<IResolver>({
// plugins: [
// new DIDResolverPlugin({
// resolver: new Resolver({
// ...ethrDidResolver({ infuraProjectId: INFURA_PROJECT_ID }),
// ...webDidResolver()
// })
// })
// ]
// });

// // const { agent } = useVeramo();
// // const resolvedDids = useCallback(async () => {
// // const resolvedDid = await agent?.resolveDid("did:web:example.com");
// // console.log("createdIdentifier -->", { resolvedDid, identifiers });
// // }, [agent]);

// // useEffect(() => {
// // if (agent) {
// // const resolveDids = resolvedDids();
// // console.log({ resolveDids });
// // }
// // }, [agent]);
export {};
25 changes: 13 additions & 12 deletions packages/sdk-v2/src/sdk/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export * from './analytics';
export * from './base';
export * from './buygd';
export * from './claim';
export * from './constants';
export * from './faucet';
export * from './ipfs';
export * from './microbridge';
export * from './newsfeed';
export * from './onboard';
export * from './savings';
export * from './storage';
export * from "./analytics";
export * from "./base";
export * from "./buygd";
export * from "./claim";
export * from "./constants";
export * from "./faucet";
export * from "./goodid";
export * from "./ipfs";
export * from "./microbridge";
export * from "./newsfeed";
export * from "./onboard";
export * from "./savings";
export * from "./storage";
102 changes: 102 additions & 0 deletions packages/sdk-v2/src/stories/goodid/CredentialsExample.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React, { useContext, useEffect, useState } from "react";
import { ComponentStory, ComponentMeta } from "@storybook/react";
// import { useVeramo, VeramoProvider } from "@veramo-community/veramo-react";
import { View, Text } from "react-native";
import { useEthers } from "@usedapp/core";

import type { VerifiableCredential } from "../../sdk/goodid/types";
import { W3Wrapper } from "../W3Wrapper";
import { GoodIdContext, GoodIdContextProvider } from "../../contexts/goodid/GoodIdContext";

const GoodIdWrapper = ({ children }) => {
return <GoodIdContextProvider>{children}</GoodIdContextProvider>;
};

enum CredentialTypes {
VerifiableLocationCredential = "Location",
VerifiableAgeCredential = "Age",
VerifiableGenderCredential = "Gender"
}

const mockCredential = {
credentialSubject: {
id: "", // example. Id will be set on server
countryCode: "US"
},
issuer: {
id: "did:key:p3Ls9vx5d7NDeqHwJG42bBxB2kzMEOgXB3tjVPQHqy1fjZrY"
},
type: ["VerifiableCredential", "VerifiableLocationCredential"],
"@context": ["https://www.w3.org/2018/credentials/v1"],
issuanceDate: "2024-02-19T08:56:34.000Z",
proof: {
type: "JwtProof2020",
jwt: "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7InlvdSI6IlJvY2sifX0sInN1YiI6ImRpZDp3ZWI6ZXhhbXBsZS5jb20iLCJuYmYiOjE3MDgzMzI5OTQsImlzcyI6ImRpZDprZXk6ejZNa3Fuc1BzakRpZnFtaEZLMjlnVmdWN2hqU0FVZlNGN2d1VVFSVHRzM2ViV3Y0In0.ViJUzFSe3l3j7opIgDhgKKx-xtiXP3RpjWckyFsnYiCEm7WOv3WTZAVLkGVNXwAsevJZ6Pg9h1X_nSRytLNJAw"
}
};

const CredentialsView = () => {
const { account } = useEthers();
const [credentials, setCredentials] = useState<VerifiableCredential[] | undefined>([]);
const { createCredential, getActiveCredentials } = useContext(GoodIdContext);

useEffect(() => {
const fetchCredentials = async () => {
if (getActiveCredentials) {
const credentials = await getActiveCredentials();

const filteredCredentials = credentials?.filter(
credential =>
credential.credentialSubject.id === account && Object.keys(CredentialTypes).includes(credential.type[1])
);
console.log("filteredCredentials", filteredCredentials);
setCredentials(filteredCredentials ?? []);
}
};

// note: does not yet consider already existing credential
const createMockCredential = async () => {
if (createCredential && account) {
mockCredential.credentialSubject.id = account; //example: only for demo purpose is this needed
await createCredential(mockCredential).then(() => fetchCredentials());
}
};

void createMockCredential();
}, [account]);

return (
<View>
<Text>Which credentials do you have verified?</Text>
{credentials?.map((credential, index) => {
return (
<View key={index}>
<Text style={{ fontWeight: "bold" }}>{CredentialTypes[credential.type[0]]}</Text>
<Text>{credential.credentialSubject.countryCode}</Text>
</View>
);
})}
</View>
);
};
const Page = (params: object) => {
return (
<W3Wrapper withMetaMask={true}>
{/* @ts-ignore */}
{/* <VeramoProvider agents={[agent]}> */}
<GoodIdWrapper>
<CredentialsView {...params} />
</GoodIdWrapper>
{/* </VeramoProvider> */}
</W3Wrapper>
);
};

export default {
title: "Example component for showing credentials from storage",
component: Page
} as ComponentMeta<typeof Page>;

const Template: ComponentStory<typeof Page> = Page;

export const CredentialsExample = Template.bind({});
Loading