-
Notifications
You must be signed in to change notification settings - Fork 21
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
[fix]: update configuration for exporting package #25
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,34 +4,25 @@ | |
"description": "SSI SDK for Onyx W3C Verifiable Credentials", | ||
"license": "Apache-2.0", | ||
"source": "src/index.ts", | ||
"types": "./lib/cjs/types/index.d.ts", | ||
"main": "./lib/cjs/index.js", | ||
"module": "./lib/esm/index.mjs", | ||
"esnext": "./lib/esm/index.mjs", | ||
"types": "./lib/esm/types/index.d.ts", | ||
"type": "commonjs", | ||
"files": [ | ||
"dist", | ||
"lib", | ||
"src", | ||
"LICENSE" | ||
], | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./lib/esm/types/index.d.ts", | ||
"default": "./lib/esm/index.mjs" | ||
}, | ||
"require": { | ||
"types": "./lib/cjs/types/index.d.ts", | ||
"default": "./lib/cjs/index.js" | ||
} | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jpmorganchase/onyx-ssi-sdk" | ||
}, | ||
"scripts": { | ||
"clean": "rm -rf ./lib", | ||
"build": "npm run clean && npm run build:esm && npm run build:cjs", | ||
"build:esm": "tsc -p ./configs/tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs", | ||
"build:esm": "tsc -p ./configs/tsconfig.esm.json", | ||
"build:cjs": "tsc -p ./configs/tsconfig.cjs.json", | ||
"prepack": "npm run build", | ||
"lint": "eslint .", | ||
|
@@ -40,6 +31,7 @@ | |
"keywords": [], | ||
"author": "", | ||
"devDependencies": { | ||
"@nomicfoundation/hardhat-toolbox": "^2.0.2", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this to |
||
"@types/jest": "^29.5.1", | ||
"@types/jsonwebtoken": "^9.0.2", | ||
"@types/mocha": "^10.0.1", | ||
|
@@ -56,7 +48,6 @@ | |
"@ethersproject/providers": "^5.6.8", | ||
"@nomicfoundation/hardhat-chai-matchers": "^1.0.3", | ||
"@nomicfoundation/hardhat-network-helpers": "^1.0.4", | ||
"@nomicfoundation/hardhat-toolbox": "^2.0.2", | ||
"@nomiclabs/hardhat-ethers": "^2.1.1", | ||
"@nomiclabs/hardhat-etherscan": "^3.1.0", | ||
"@nomiclabs/hardhat-solhint": "^2.0.1", | ||
|
@@ -65,6 +56,8 @@ | |
"@typechain/hardhat": "^6.1.2", | ||
"@types/chai": "^4.3.5", | ||
"@types/lodash": "^4.14.194", | ||
"ajv": "^8.12.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaced incompatible |
||
"ajv-formats": "^3.0.1", | ||
"axios": "^1.3.5", | ||
"chai": "^4.3.7", | ||
"did-jwt": "6.11.6", | ||
|
@@ -74,9 +67,8 @@ | |
"ethr-did-resolver": "^8.0.0", | ||
"hardhat": "^2.14.0", | ||
"hardhat-gas-reporter": "^1.0.9", | ||
"jsonschema": "^1.4.1", | ||
"jsonwebtoken": "^9.0.0", | ||
"key-did-resolver": "1.4.0", | ||
"jose": "^5.2.4", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The jsonwebtoken library is targeting node enviroments. I replaced it with https://github.com/panva/jose |
||
"key-did-resolver": "^1.4.0", | ||
"lodash": "^4.17.21", | ||
"loglevel": "^1.8.1", | ||
"solidity-coverage": "^0.8.2", | ||
|
@@ -86,5 +78,8 @@ | |
"overrides": { | ||
"flat": ">=5.0.1", | ||
"minimatch": ">=3.0.5" | ||
}, | ||
"browser": { | ||
"fs": false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This prevents bundler for containing incompatible |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { DIDResolutionResult, DIDResolver, Resolver } from "did-resolver"; | ||
import {randomBytes} from "crypto" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
import { utils } from 'ethers'; | ||
import { DID, DIDMethod, DIDWithKeys } from "./did"; | ||
import { KeyUtils, KEY_ALG } from "../../../utils"; | ||
import { getResolver } from "key-did-resolver"; | ||
|
@@ -15,7 +15,7 @@ export class KeyDIDMethod implements DIDMethod { | |
*/ | ||
async create(): Promise<DIDWithKeys> { | ||
const seed = () => { | ||
return randomBytes(32) | ||
return utils.randomBytes(32) | ||
} | ||
|
||
const key = await Ed25519KeyPair.generate({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { CredentialPayload, PresentationPayload, createVerifiableCredentialJwt, | |
import { ES256KSigner, hexToBytes, EdDSASigner } from 'did-jwt' | ||
import { KEY_ALG } from "../../../utils"; | ||
import { isString } from 'lodash' | ||
import {decode} from 'jsonwebtoken'; | ||
import { decodeJwt, decodeProtectedHeader } from 'jose'; | ||
|
||
export class JWTService implements SignatureService { | ||
name = 'JWT' | ||
|
@@ -97,7 +97,10 @@ export class JWTService implements SignatureService { | |
* @return decoded JWT object {header, payload, signature} | ||
*/ | ||
decodeJWT(token: JWT) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we could add a simpler |
||
return decode(token, {complete:true}) | ||
const header = decodeProtectedHeader(token) | ||
const payload = decodeJwt(token); | ||
const signature = token.split('.')[2] | ||
return { header, payload, signature } | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,10 @@ export class HelperUtils { | |
* Throws `ReadFileJsonFailureError` if reading or parsing fails | ||
*/ | ||
static async fileReaderJSON(location: string) { | ||
if (typeof window !== 'undefined') { | ||
// Check if we are in a browser env | ||
throw Error(`Operation 'fileReaderJSON' not supported in browser enviroment`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Throwing error, if caller wants to use this function, in web enviroment. |
||
} | ||
try { | ||
const fileText = fs.readFileSync(location, 'utf-8'); | ||
return HelperUtils.parseJSON(fileText) | ||
|
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.
The renaming is unnecessary.