identity-com / sol-did

Specification for the did:sol method
MIT License
51 stars 19 forks source link

**ERROR:** Buffer is not defined at _getPDAKeyFromAuthority (sol-data.ts:19:8) #234

Closed chongkan closed 5 months ago

chongkan commented 5 months ago

I am trying to test the implementation in a Vue.js Application.

**ERROR:**  Buffer is not defined at _getPDAKeyFromAuthority (sol-data.ts:19:8)
 import * as SolDiD from '@identity.com/sol-did-client';

 const didSolIdentifier = SolDiD.DidSolIdentifier.create(response.publicKey, 'devnet');
            console.log('DID Sol Identifier:', didSolIdentifier.toString());
            const service = await SolDiD.DidSolService.build(didSolIdentifier);
            const didDoc = await service.resolve(); // This line causes an error 

When I look at the file in question, it seems to be missing the import for Buffer. ?

Documentation Feedback: in http://g.identity.com/sol-did/#create

The documentation is not clear. e.g. It makes a difference between IDENTIFIER and AUTHORITY, which I asumed was a derived address from the AUTHORITY, which led me to attempt to create a didDoc off-chain to later use the clint lib to push it on-chain if the user decided it was time or when it was complete. -> https://gist.github.com/chongkan/a78803c61211ee592fec1666316191ac

Then, when I moved on, tried the above methods and the DID generated by the Client Lib is simple a concatenation of the wallet public_key.

e.g. did:sol:(network:){walletAddress}

image
chongkan commented 5 months ago

Update: The error was due to my project config not using Node Polyfills. I resolved it by installing

$ yarn/npm vite-plugin-node-polyfills

Then in the vite.config.js

import { nodePolyfills } from 'vite-plugin-node-polyfills' ;

Then in the plugins section, add nodePoly

image