-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
6a74ae6
to
804d260
Compare
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, | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
804d260
to
703befe
Compare
Signed-off-by: Berend Sliedrecht <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Berend Sliedrecht <[email protected]>
703befe
to
bc98c1c
Compare
} else if (!offerUri) { | ||
throw new Error('either data or uri must be provided') | ||
throw new Error("either data or uri must be provided"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the formatting change?
There was a problem hiding this comment.
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.
bc98c1c
to
223c9d0
Compare
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', | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]>
223c9d0
to
1158ded
Compare
Builds ontop of #125