Skip to content

Commit

Permalink
feat: add cspell (#267)
Browse files Browse the repository at this point in the history
* add spellcheck
  • Loading branch information
volodymyr-basiuk authored Sep 11, 2024
1 parent 6b6b674 commit c55fbab
Show file tree
Hide file tree
Showing 21 changed files with 1,823 additions and 299 deletions.
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const iden3Config = require('@iden3/eslint-config');
const { spellcheckerRule, cspellConfig } = require('@iden3/eslint-config/cspell');

module.exports = {
...iden3Config,
rules: {
'@cspell/spellchecker': [
1,
{
...spellcheckerRule,
cspell: {
...cspellConfig,
ignoreWords: ['unmarshal', 'JUvpllMEYUZ2joO59UNui_XYDqxVqiFLLAJ8klWuPBw', 'gdwj', 'fwor']
}
}
]
}
};
2,006 changes: 1,757 additions & 249 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
},
"homepage": "https://github.com/0xPolygonID/js-sdk#readme",
"devDependencies": {
"@cspell/eslint-plugin": "^8.14.2",
"@gr2m/fetch-mock": "9.11.0-pull-request-644.1",
"@iden3/eslint-config": "https://github.com/iden3/eslint-config",
"@microsoft/api-documenter": "^7.8.20",
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/status/on-chain-revocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class OnChainResolver implements CredentialStatusResolver {
return network;
}

// TODO (illia-korotia): is dirty hack for mock in tests.
// TODO: is dirty hack for mock in tests.
// need to pass to constructor list of state stores not list of network configs
private _getStateStorageForIssuer(issuerId: Id): IStateStorage {
const issuerChainId = getChainId(DID.blockchainFromId(issuerId), DID.networkIdFromId(issuerId));
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/status/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface CredentialStatusResolveOptions {
}

/**
* CredentialStatusResolver is an interface that allows to interact with deifferent types of credential status
* CredentialStatusResolver is an interface that allows to interact with different types of credential status
* to resolve revocation status
*
* @public
Expand Down
8 changes: 4 additions & 4 deletions src/proof/provers/witness_calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ function fnvHash(str: any) {
hash *= BigInt(0x100000001b3);
hash %= uint64_max;
}
let shash = hash.toString(16);
const n = 16 - shash.length;
shash = '0'.repeat(n).concat(shash);
return shash;
let hashHex = hash.toString(16);
const n = 16 - hashHex.length;
hashHex = '0'.repeat(n).concat(hashHex);
return hashHex;
}
2 changes: 1 addition & 1 deletion src/storage/blockchain/onchain-revocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class OnChainRevocationStorage {
*
* Creates an instance of OnChainIssuer.
* @public
* @param {string} - onhcain contract address
* @param {string} - onchain contract address
* @param {string} - rpc url to connect to the blockchain
*/

Expand Down
4 changes: 2 additions & 2 deletions src/verifiable/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const VerifiableConstants = Object.freeze({
PUSH_NOTIFICATION: 'push-notification'
},
AUTH: {
AUTH_BJJ_CREDENTAIL_HASH: '013fd3f623559d850fb5b02ff012d0e2',
AUTH_BJJ_CREDENTIAL_HASH: '013fd3f623559d850fb5b02ff012d0e2',
AUTH_BJJ_CREDENTIAL_SCHEMA_JSON_URL: 'https://schema.iden3.io/core/json/auth.json',
AUTH_BJJ_CREDENTIAL_SCHEMA_JSONLD_URL: 'https://schema.iden3.io/core/jsonld/auth.jsonld',
AUTH_BJJ_CREDENTIAL_TYPE: 'AuthBJJCredential',
Expand Down Expand Up @@ -63,7 +63,7 @@ export enum CredentialStatusType {
Iden3ReverseSparseMerkleTreeProof = 'Iden3ReverseSparseMerkleTreeProof',
// Iden3commRevocationStatusV1 is CredentialStatusType for iden3comm revocation status
Iden3commRevocationStatusV1 = 'Iden3commRevocationStatusV1.0',
// Iden3OnсhainSparseMerkleTreeProof2023 is a proof type for MTP proofs with iden3 metadata from blockchain
// Iden3OnchainSparseMerkleTreeProof2023 is a proof type for MTP proofs with iden3 metadata from blockchain
Iden3OnchainSparseMerkleTreeProof2023 = 'Iden3OnchainSparseMerkleTreeProof2023'
}

Expand Down
2 changes: 1 addition & 1 deletion src/verifiable/credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export class W3CCredential {
resolverURL: string
): Promise<boolean> {
await validateDIDDocumentAuth(proof.issuerData.id, resolverURL, proof.issuerData.state.value);
// root from proof == issuerData.state.сlaimsTreeRoot
// root from proof == issuerData.state.claimsTreeRoot
const { hi, hv } = coreClaim.hiHv();
const rootFromProofValue = await rootFromProof(proof.mtp, hi, hv);
if (!rootFromProofValue.equals(proof.issuerData.state.claimsTreeRoot)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/circuits/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const TestClaimDocument = `{
"givenName": "JOHN",
"familyName": "SMITH",
"gender": "Male",
"image": "data:image/png;base64,iVBORw0KGgokJggg==",
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII",
"residentSince": "2015-01-01",
"lprCategory": "C09",
"lprNumber": "999-999-999",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ describe('onchain revocation checks', () => {
});

const { did: issuerDID, credential: issuerAuthCredential } = await createIdentity(idWallet, {
seed: byteEncoder.encode('soedseedseedseedseedseedseedseed'),
seed: byteEncoder.encode('seedseedseedseedseedseed11issuer'),
revocationOpts: {
id,
type: CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023,
Expand All @@ -350,7 +350,7 @@ describe('onchain revocation checks', () => {
const callBackUseCase = new Promise((resolve) => {
(async () => {
const { did: userDID, credential: userAuthCredential } = await createIdentity(idWallet, {
seed: byteEncoder.encode('seedseedseedseedseedseedseedseex'),
seed: byteEncoder.encode('seedseedseedseedseedseedseeduser'),
revocationOpts: {
id,
type: CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023,
Expand Down
4 changes: 2 additions & 2 deletions tests/credentials/credential-wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ const credentialFlow = async (storage: IDataStorage) => {
);

// remove credential error
await expect(credentialWallet.remove('unknowId')).to.be.rejectedWith(
'item not found to delete: unknowId'
await expect(credentialWallet.remove('unknownId')).to.be.rejectedWith(
'item not found to delete: unknownId'
);

await credentialWallet.remove('test1');
Expand Down
20 changes: 10 additions & 10 deletions tests/handlers/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('auth', () => {
const authReqBody: AuthorizationRequestMessageBody = {
callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123',
reason: 'reason',
message: 'mesage',
message: 'message',
did_doc: {},
scope: [proofReq as ZeroKnowledgeProofRequest]
};
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('auth', () => {
const authReqBody: AuthorizationRequestMessageBody = {
callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123',
reason: 'reason',
message: 'mesage',
message: 'message',
did_doc: {},
scope: [proofReq as ZeroKnowledgeProofRequest]
};
Expand Down Expand Up @@ -385,7 +385,7 @@ describe('auth', () => {
const authReqBody: AuthorizationRequestMessageBody = {
callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123',
reason: 'reason',
message: 'mesage',
message: 'message',
did_doc: {},
scope: proofReqs
};
Expand Down Expand Up @@ -549,7 +549,7 @@ describe('auth', () => {
const authReqBody: AuthorizationRequestMessageBody = {
callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123',
reason: 'reason',
message: 'mesage',
message: 'message',
did_doc: {},
scope: proofReqs
};
Expand Down Expand Up @@ -791,7 +791,7 @@ describe('auth', () => {
const authReqBody: AuthorizationRequestMessageBody = {
callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123',
reason: 'reason',
message: 'mesage',
message: 'message',
did_doc: {},
scope: proofReqs
};
Expand Down Expand Up @@ -1466,7 +1466,7 @@ describe('auth', () => {
body: {
callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123',
reason: 'reason',
message: 'mesage',
message: 'message',
did_doc: {},
scope: [
{
Expand Down Expand Up @@ -1535,12 +1535,12 @@ describe('auth', () => {
};

const response = JSON.parse(
`{"id":"9f8c5eaf-761b-45a3-9291-e716809ace80","typ":"application/iden3-zkp-json","type":"https://iden3-communication.io/authorization/1.0/response","thid":"f1db2356-9f44-48ad-9b76-f89d47f21f6a","body":{"message":"mesage","scope":[{"id":1,"circuitId":"credentialAtomicQueryV3-beta.1","proof":{"pi_a":["1957042983521939777779358613512940538748371001503599796504079991585151845626","5980467088491530700980741867186770936154186459285094575907693303048036963689","1"],"pi_b":[["5742671146783049896789457637506168650313117608892287762091826086179746860469","7867980002214299883401553001814837114723536790472835510365975534274190677490"],["6409919485783982335585179727042442194321707383499872699189740318445051390961","1369980068779537226244190127504408237299520988801560937733214682094782613117"],["1","0"]],"pi_c":["5711121494820066463200893985386651555980045684596061159643138162113786427802","4095818364808367579242275974249584152089253995861921406668522195898158853090","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["0","21568225469889458305914841490175280093555015071329787375641431262509208065","4487386332479489158003597844990487984925471813907462483907054425759564175341","0","0","0","1","1","25191641634853875207018381290409317860151551336133597267061715643603096065","1","4487386332479489158003597844990487984925471813907462483907054425759564175341","1709225461","198285726510688200335207273836123338699","0","3","1","99","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","25191641634853875207018381290409317860151551336133597267061715643603096065","0"]},{"id":2,"circuitId":"linkedMultiQuery10-beta.1","proof":{"pi_a":["10008762987135252748343336852440821999292200194586609431123158877924829442619","643120883606370243165315267728925724383441131555632496875810966571180142836","1"],"pi_b":[["20325202427888218305042001051611691791013545949589864140437875458628437599770","8717600144533993361171658192288756446811108221293161636717237909993926710318"],["14981619958191157581227114000872054457371373393565997302166302876147503284338","16553636587728487263592580154123194292472350845107268041191122057483030032517"],["1","0"]],"pi_c":["16072126589976107857236142821613193518209749401521398065019425748092192614959","303906682296869502342276988123716958990500798695456357531107835924939259150","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["14840595334989550616466083197180000787621620083536890923904228235213356726165","1","0","0","0","0","0","0","0","0","0","0","15577114799056939633552845531011024672939493492769628285661359711655214561162","16998762965396944782667557741185828136467747762830028217027973617373862301958","9302526208507753799501130128908494673412443631541424409551205277529949662394","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403"]},{"id":3,"circuitId":"credentialAtomicQueryV3-beta.1","proof":{"pi_a":["4918421968222994875065132919357788716527410020013314076838075601739876838116","10576714801149162526665883185954136825228282980216373802495776414648547250389","1"],"pi_b":[["11108578138197665525735155920251801717888098160693764639454679880928722733880","3997721247159844618817277585055198811110117246676622629879543401795646667027"],["20635473172141447711225783196574171578493742575849493414547293568487122129963","6948443179619059689387710642006412901626278322232965354300544053846217743110"],["1","0"]],"pi_c":["469119326794229447935775203453233806548971393125675053242929084072054328769","178813906627150338283979844326455982590598033322249897359697376726879654625","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["1","21568225469889458305914841490175280093555015071329787375641431262509208065","4487386332479489158003597844990487984925471813907462483907054425759564175341","14840595334989550616466083197180000787621620083536890923904228235213356726165","21051816437711998017249050444244727806861025707804897813951842286690382472927","0","1","3","25191641634853875207018381290409317860151551336133597267061715643603096065","1","4487386332479489158003597844990487984925471813907462483907054425759564175341","1709225477","219578617064540016234161640375755865412","1296351758269061173317105041968067077451914386086222931516199194959869463882","0","1","1702252800000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","25191641634853875207018381290409317860151551336133597267061715643603096065","12345"]}]},"from":"did:iden3:polygon:mumbai:wuw5tydZ7AAd3efwEqPprnqjiNHR24jqruSPKmV1V","to":"did:iden3:polygon:mumbai:wzokvZ6kMoocKJuSbftdZxTD6qvayGpJb3m4FVXth"}`
`{"id":"9f8c5eaf-761b-45a3-9291-e716809ace80","typ":"application/iden3-zkp-json","type":"https://iden3-communication.io/authorization/1.0/response","thid":"f1db2356-9f44-48ad-9b76-f89d47f21f6a","body":{"message":"message","scope":[{"id":1,"circuitId":"credentialAtomicQueryV3-beta.1","proof":{"pi_a":["1957042983521939777779358613512940538748371001503599796504079991585151845626","5980467088491530700980741867186770936154186459285094575907693303048036963689","1"],"pi_b":[["5742671146783049896789457637506168650313117608892287762091826086179746860469","7867980002214299883401553001814837114723536790472835510365975534274190677490"],["6409919485783982335585179727042442194321707383499872699189740318445051390961","1369980068779537226244190127504408237299520988801560937733214682094782613117"],["1","0"]],"pi_c":["5711121494820066463200893985386651555980045684596061159643138162113786427802","4095818364808367579242275974249584152089253995861921406668522195898158853090","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["0","21568225469889458305914841490175280093555015071329787375641431262509208065","4487386332479489158003597844990487984925471813907462483907054425759564175341","0","0","0","1","1","25191641634853875207018381290409317860151551336133597267061715643603096065","1","4487386332479489158003597844990487984925471813907462483907054425759564175341","1709225461","198285726510688200335207273836123338699","0","3","1","99","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","25191641634853875207018381290409317860151551336133597267061715643603096065","0"]},{"id":2,"circuitId":"linkedMultiQuery10-beta.1","proof":{"pi_a":["10008762987135252748343336852440821999292200194586609431123158877924829442619","643120883606370243165315267728925724383441131555632496875810966571180142836","1"],"pi_b":[["20325202427888218305042001051611691791013545949589864140437875458628437599770","8717600144533993361171658192288756446811108221293161636717237909993926710318"],["14981619958191157581227114000872054457371373393565997302166302876147503284338","16553636587728487263592580154123194292472350845107268041191122057483030032517"],["1","0"]],"pi_c":["16072126589976107857236142821613193518209749401521398065019425748092192614959","303906682296869502342276988123716958990500798695456357531107835924939259150","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["14840595334989550616466083197180000787621620083536890923904228235213356726165","1","0","0","0","0","0","0","0","0","0","0","15577114799056939633552845531011024672939493492769628285661359711655214561162","16998762965396944782667557741185828136467747762830028217027973617373862301958","9302526208507753799501130128908494673412443631541424409551205277529949662394","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403","14612518006493998037149299647974237771551070312096882407440651052752259038403"]},{"id":3,"circuitId":"credentialAtomicQueryV3-beta.1","proof":{"pi_a":["4918421968222994875065132919357788716527410020013314076838075601739876838116","10576714801149162526665883185954136825228282980216373802495776414648547250389","1"],"pi_b":[["11108578138197665525735155920251801717888098160693764639454679880928722733880","3997721247159844618817277585055198811110117246676622629879543401795646667027"],["20635473172141447711225783196574171578493742575849493414547293568487122129963","6948443179619059689387710642006412901626278322232965354300544053846217743110"],["1","0"]],"pi_c":["469119326794229447935775203453233806548971393125675053242929084072054328769","178813906627150338283979844326455982590598033322249897359697376726879654625","1"],"protocol":"groth16","curve":"bn128"},"pub_signals":["1","21568225469889458305914841490175280093555015071329787375641431262509208065","4487386332479489158003597844990487984925471813907462483907054425759564175341","14840595334989550616466083197180000787621620083536890923904228235213356726165","21051816437711998017249050444244727806861025707804897813951842286690382472927","0","1","3","25191641634853875207018381290409317860151551336133597267061715643603096065","1","4487386332479489158003597844990487984925471813907462483907054425759564175341","1709225477","219578617064540016234161640375755865412","1296351758269061173317105041968067077451914386086222931516199194959869463882","0","1","1702252800000000000","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","25191641634853875207018381290409317860151551336133597267061715643603096065","12345"]}]},"from":"did:iden3:polygon:mumbai:wuw5tydZ7AAd3efwEqPprnqjiNHR24jqruSPKmV1V","to":"did:iden3:polygon:mumbai:wzokvZ6kMoocKJuSbftdZxTD6qvayGpJb3m4FVXth"}`
) as AuthorizationResponseMessage;
await authHandler.handleAuthorizationResponse(response, authRequest, TEST_VERIFICATION_OPTS);
});

it('null scope auth requst', async () => {
it('null scope auth request', async () => {
const msgBytes = byteEncoder.encode(
'{"id":"f3688b54-248d-4a75-b743-39f99a49adb8","typ":"application/iden3comm-plain-json","type":"https://iden3-communication.io/authorization/1.0/request","thid":"f3688b54-248d-4a75-b743-39f99a49adb8","body":{"callbackUrl":"https://issuer-admin.polygonid.me/v1/credentials/links/callback?sessionID=1bd6b1cb-cfc1-4817-8b77-3bc150435e29\u0026linkID=880face8-43b7-428b-80b1-adb6da0632ac","reason":"authentication","scope":null},"from":"did:polygonid:polygon:mumbai:2qMLpQ5py1YzBTTuLEeX2yr6pDGQ7gyXAfygaPakzq"}'
);
Expand Down Expand Up @@ -2091,7 +2091,7 @@ describe('auth', () => {
const authReqBody: AuthorizationRequestMessageBody = {
callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123',
reason: 'reason',
message: 'mesage',
message: 'message',
did_doc: {},
scope: proofReqs
};
Expand Down Expand Up @@ -2156,7 +2156,7 @@ describe('auth', () => {
const authReqBody: AuthorizationRequestMessageBody = {
callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123',
reason: 'reason',
message: 'mesage',
message: 'message',
did_doc: {},
scope: [proofReq as ZeroKnowledgeProofRequest]
};
Expand Down
Loading

0 comments on commit c55fbab

Please sign in to comment.