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

support PoL verification from synaps #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

ilya-korotya
Copy link
Collaborator

No description provided.

@@ -0,0 +1,26 @@
module.exports = {

Choose a reason for hiding this comment

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

could we reuse @iden3/eslint-config that we have already defined (common linter for all js projects) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Choose a reason for hiding this comment

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

Aren't you still missing the extends here?

extends: ["@iden3/eslint-config"],

"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {

Choose a reason for hiding this comment

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

i don't see @0xpolygonid/js-sdk in dependencies

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

};
}

private _getProposalMessage(

Choose a reason for hiding this comment

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

nit: we have functions like createProposal and createProposalRequest in sdk, that can create specific protocol message, so you could use them

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay. But I want to note that the from and to fields are optional in the iden3comm protocol, but in the JS sdk they are required fields. We need to fix these createSomeMessages ...
@vmidyllic @Kolezhniuk

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Kolezhniuk also I need to possibility pass custom thid. This method from the js-sdk doens't okay for me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Choose a reason for hiding this comment

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

We need to fix these createSomeMessages

What do you mean when you say "we need to fix them"? It's ok that the types in the SDK make from and to required, even if they are optional in the more generic iden3comm protocol.

src/agent/agent.controller.ts Outdated Show resolved Hide resolved
src/agent/agent.controller.ts Show resolved Hide resolved
src/agent/agent.service.ts Show resolved Hide resolved
src/agent/agent.service.ts Show resolved Hide resolved
src/setup/sdk.ts Outdated Show resolved Hide resolved
src/setup/sdk.ts Outdated
});

const proofService = new ProofService(
{} as any,

Choose a reason for hiding this comment

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

it is not right to pass mocked wallets.. !

Copy link
Collaborator Author

@ilya-korotya ilya-korotya Oct 10, 2024

Choose a reason for hiding this comment

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

Why? I don't want to initialise the wallet service because I don't generate any proofs. We need to have a flexible sdk and not ask the user to initialise parts they don't need.

Choose a reason for hiding this comment

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

You can implement interface IProofService with implementation that only you need. It is not right to pass objects as 'any'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. But I don't need any thing from IProofService interface

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Choose a reason for hiding this comment

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

what is done?
you pass empty object still.

RPC_URL=https://rpc-mainnet.privado.id
STATE_CONTRACT_ADDRESS=0x975556428F077dB5877Ea2474D783D6C69233742

AGENT_URL=<NGROK_URL_TO_PROXY_REQUESTS_FROM_WORLD>

Choose a reason for hiding this comment

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

I'd say PUBLICLY_ACCESSIBLE_URL_TO_PROXY_REQUESTS

@@ -0,0 +1,26 @@
module.exports = {

Choose a reason for hiding this comment

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

Aren't you still missing the extends here?

extends: ["@iden3/eslint-config"],

private _validateBasicMessage(basicMessage: BasicMessage) {
if (!basicMessage.from || !basicMessage.to) {
throw new Error(
"Invalid basic message: 'from' and 'to' fields cannot be empty",

Choose a reason for hiding this comment

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

Wouldn't it make sense to make these required at the SDK? (I don't mean now, but at some point)

private _validateProposalRequestMessage(
proposalMessageBody: ProposalRequestMessage,
) {
if (!proposalMessageBody.body) {

Choose a reason for hiding this comment

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

Isn't this check unnecessary being body a required prop in a ProposalRequestMessage?

}

private _validateProposalRequestMessage(
proposalMessageBody: ProposalRequestMessage,

Choose a reason for hiding this comment

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

This should be named proposalRequestMessage

"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,

Choose a reason for hiding this comment

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

We should change this to true and add:

"noUncheckedIndexedAccess": true,

const credentialContext = proposalMessageBody.body.credentials[0].context;
if (credentialContext !== SupportedCredential.JsonLDSchema) {
throw new Error(
`Invalid credential context: '${credentialContext}' is not supported`,

Choose a reason for hiding this comment

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

This can lead to the msg

Invalid credential context: undefined is not supported

Instead, we should make sure the credential is available first.

I'd go this way:

const [credential, ...rest] = proposalMessageBody.body.credentials;

if (!credential || rest.length > 0) {
  throw new Error(
    "Invalid proposal message body: 'credentials' field must contain exactly one credential",
  );
}

// credential is defined

const credentiaType = proposalMessageBody.body.credentials[0].type;
if (credentiaType !== SupportedCredential.Type) {
throw new Error(
`Invalid credential type: '${credentiaType}' is not supported`,

Choose a reason for hiding this comment

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

Same as before. credentiaType can be undefined here.

`Invalid credential context: '${credentialContext}' is not supported`,
);
}
const credentiaType = proposalMessageBody.body.credentials[0].type;

Choose a reason for hiding this comment

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

credentialType

switch (unpackedMessage.type) {
case PROTOCOL_CONSTANTS.PROTOCOL_MESSAGE_TYPE
.PROPOSAL_REQUEST_MESSAGE_TYPE:
const proposalRequest = unpackedMessage as ProposalRequestMessage;

Choose a reason for hiding this comment

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

I don't expect any changes here now, but let me add a thought:

The SDK's packageMgr.unpack should return properly typed messages so we can switch/case its type and don't need these type-assertions in the client.

And while it doesn't, the client should be parsing the msg instead of type-asserting it.

export interface ICreateCredentialRequest {
credentialSchema: string;
type: string;
credentialSubject: { [key: string]: any };

Choose a reason for hiding this comment

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

This should use the type JSONObject from the SDK.

IPacker,
ProvingParams,
} from '@0xpolygonid/js-sdk';
// import { path } from 'path';

Choose a reason for hiding this comment

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

leftover?

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.

5 participants