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

store seed credential #129

Merged
merged 5 commits into from
Aug 1, 2024
Merged

store seed credential #129

merged 5 commits into from
Aug 1, 2024

Conversation

berendsliedrecht
Copy link
Member

@berendsliedrecht berendsliedrecht commented Jul 30, 2024

Builds ontop of #125

@berendsliedrecht berendsliedrecht force-pushed the store-seed-credential branch 2 times, most recently from 6a74ae6 to 804d260 Compare July 30, 2024 12:30
Comment on lines 4 to 28
const store = async (context: AgentContext, id: string, value: Record<string, unknown>) => {
const wallet = context.wallet
assertAskarWallet(wallet)

wallet.withSession(async (session) => {
session.insert({
name: id,
value: JSON.stringify(value),
category: 'genericStorageRecord',
})
})
}

const replace = async (context: AgentContext, id: string, value: Record<string, unknown>) => {
const wallet = context.wallet
assertAskarWallet(wallet)

wallet.withSession(async (session) => {
session.replace({
name: id,
value: JSON.stringify(value),
category: 'genericStorageRecord',
})
})
}

const getById = async <T extends Record<string, unknown>>(context: AgentContext, id: string): Promise<T> => {
const wallet = context.wallet
assertAskarWallet(wallet)

const item = await wallet.withSession(async (session) =>
session.fetch({
name: id,
category: 'genericStorageRecord',
})
)

if (!item) {
throw new Error(`No generic item with id: ${id} found`)
}

const transformedValue = item.value === 'string' ? JSON.parse(item.value) : item.value

return transformedValue as T
}

export const walletJsonStore = {
store,
getById,
replace,
}
Copy link
Member

Choose a reason for hiding this comment

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

We have agent.genericRecords for this. No need to use askar directory.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah makes sense, will swap.

Berend Sliedrecht and others added 4 commits July 30, 2024 15:29
Signed-off-by: Berend Sliedrecht <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
} else if (!offerUri) {
throw new Error('either data or uri must be provided')
throw new Error("either data or uri must be provided");
Copy link
Member

Choose a reason for hiding this comment

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

why the formatting change?

Copy link
Member Author

Choose a reason for hiding this comment

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

I still have prettier setup, will run biome again...just a mistake.

Comment on lines 125 to 151
if (didMethod) {
const didResult = await agent.dids.create<JwkDidCreateOptions | KeyDidCreateOptions>({
method: didMethod,
options: {
key,
},
})

if (didResult.didState.state !== 'finished') {
throw new Error('DID creation failed.')
}

let verificationMethodId: string
if (didMethod === 'jwk') {
const didJwk = DidJwk.fromDid(didResult.didState.did)
verificationMethodId = didJwk.verificationMethodId
} else {
const didKey = DidKey.fromDid(didResult.didState.did)
verificationMethodId = `${didKey.did}#${didKey.key.fingerprint}`
}

return {
didUrl: verificationMethodId,
method: 'did',
}
}

Copy link
Member

Choose a reason for hiding this comment

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

why did you remove this? This is needed for the Paradym WAllet?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think there was a reason, was just a bit too focussed on Funke wallet. Will revert.

Signed-off-by: Berend Sliedrecht <[email protected]>
@berendsliedrecht berendsliedrecht merged commit e201857 into main Aug 1, 2024
1 check passed
@berendsliedrecht berendsliedrecht deleted the store-seed-credential branch August 1, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants