ceramicnetwork / js-did

A simple interface to interact with DIDs that conform to the DID-provider interface.
Other
95 stars 28 forks source link

docs: wrong code snippet in Using With ComposeDB Client #116

Closed agnes512 closed 1 year ago

agnes512 commented 1 year ago

Description

The code snippet on Using With ComposeDB Client is inconsistent.

In

import { DIDSession } from 'did-session'
import type { AuthMethod } from '@didtools/cacao'
import { EthereumWebAuth, getAccountId } from '@didtools/pkh-ethereum'

const ethProvider = // import/get your web3 eth provider
const addresses = await ethProvider.enable()
const accountId = await getAccountId(ethProvider, addresses[0])
const authMethod = await EthereumWebAuth.getAuthMethod(ethProvider, accountId)

const loadSession = async(authMethod: AuthMethod, resources: Array<string>):Promise<DIDSession> => {
  return DIDSession.authorize(authProvider, { resources })
}

const session = await loadSession(authProvider, compose.resources)

THe AuthMethod param is not compatible with the function DIDSession.authorize(authProvider, { resources }) Also authProvider is not defined in the doc

Technical Information

type errors & missing definition

stbrody commented 1 year ago

FYI @mattdavis0351 @zachferland @PaulLeCam

zachferland commented 1 year ago

thanks! fixing in my current docs pr, will be updated shortly

zachferland commented 1 year ago

fix deployed, closing, thanks

agnes512 commented 1 year ago

@zachferland the authMethod: AuthMethod is not compatible with DIDSession.authorize which is authorize(authProvider: EthereumAuthProvider, authOpts?: AuthOpts): Promise<DIDSession>;

I am not sure if it is because id-session version I am using ("0.1.4") is different from yours

zachferland commented 1 year ago

docs are for did-session@1.x.x now it is released, this section explains the difference and how you can upgrade - https://did.js.org/docs/api/modules/did_session#upgrading-from-did-session0xx-to-did-session1xx