Tonomy-Foundation / Tonomy-ID-SDK

This Software Development Kit is used in Tonomy ID to interact and call with the Antelope blockchain and services. It is also used as the public API for integration by applications to do single sign-on, share credentials and sign transactions.
https://tonomy-id-sdk-tonomy-foundation.vercel.app
Apache License 2.0
5 stars 1 forks source link

Upgrade to latest did-jwt #336

Open theblockstalk opened 5 months ago

theblockstalk commented 5 months ago

Upgrade to the latest version of this library Would provide additional security and functional upgrades, as well as put us in a position to start using the Veramo library. See task https://github.com/Tonomy-Foundation/Tonomy-ID-SDK/issues/337

Why have we not done this yet:

Repositories

Also need to upgrade:

theblockstalk commented 1 month ago

I have found 1 solution so far which allows resolution with jest, using the following in the jest.config.ts file which you can see in in PR commit https://github.com/Tonomy-Foundation/Tonomy-ID-SDK/pull/394/commits/22e19041e002344fe31410962208dc896ed3dcbd

moduleNameMapper: {
        // This is a workaround for the following packages that use conditional exports in package.json which jest does not support yet
        "^uint8arrays$": "<rootDir>/node_modules/uint8arrays/esm/src/index.js",
        "^@ipld/dag-pb*": "<rootDir>/node_modules/@ipld/dag-pb/src/index.js",
        "^multiformats/(.*)$": "<rootDir>/node_modules/multiformats/dist/src/$1.js",
        "^ipfs-unixfs$": "<rootDir>/node_modules/ipfs-unixfs/dist/src/index.js",
        "^protons-runtime$": "<rootDir>/node_modules/protons-runtime/dist/src/index.js",
        "^uint8-varint$": "<rootDir>/node_modules/uint8-varint/dist/src/index.js",
        "^uint8arrays/(.*)$": "<rootDir>/node_modules/uint8arrays/esm/src/$1.js",
    }
theblockstalk commented 1 month ago

also tried, unsucessfully:

changing jest.config.ts:

jest-resolver.cjs

const defaultResolver = require('jest-resolve').default;
const path = require('path');

// use the import field in package.json to resolve the module manually
module.exports = (request, options) => {
    // Attempt to resolve using the default resolver
    try {
        return defaultResolver(request, options);
    } catch (e) {
        // If the resolution fails, attempt to resolve using "exports"
        const modulePath = path.join(options.basedir, 'node_modules', request);
        const pkgPath = path.join(modulePath, 'package.json');

        try {
            const pkg = require(pkgPath);
            if (pkg.exports && pkg.exports.import) {
                return path.join(modulePath, pkg.exports.import);
            }
        } catch (innerError) {
            // If anything goes wrong, throw the original error
            throw innerError;
        }
    }
};

// explicitly specify the conditions to resolve the module
module.exports = (path, options) => {
    // Call the defaultResolver, so we leverage its cache, error handling, etc.
    return options.defaultResolver(path, {
        ...options,
        conditions: ["default", "import"]
    });
};
theblockstalk commented 1 month ago

See https://github.com/decentralized-identity/veramo/issues/1250#issuecomment-1821335010

theblockstalk commented 4 weeks ago

Good chat here with Veramo author https://discord.com/channels/878293684620234752/1200026960307437578/1249720913390469245