Skip to content

Commit

Permalink
Merge pull request #180 from Sphereon-Opensource/feature/DPP-127-fixes
Browse files Browse the repository at this point in the history
feature/SDK-1
  • Loading branch information
BtencateSphereon authored Feb 22, 2024
2 parents 727c4f2 + 7aa7131 commit bcb5f45
Show file tree
Hide file tree
Showing 38 changed files with 3,880 additions and 3,351 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEBUG=*
1 change: 1 addition & 0 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {NavigationContainer} from '@react-navigation/native';
import crypto from '@sphereon/isomorphic-webcrypto';
import {backgroundColors} from '@sphereon/ui-components.core';
import debug from 'debug';
import * as SplashScreen from 'expo-splash-screen';
import * as React from 'react';
import {useCallback, useEffect, useState} from 'react';
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['@babel/plugin-syntax-import-assertions'],
plugins: ['@babel/plugin-syntax-import-assertions', 'module:react-native-dotenv'],
};
};
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'react-native-get-random-values';
import '@ethersproject/shims';
import 'fast-text-encoding';
import 'react-native-gesture-handler';
import 'react-native-url-polyfill/auto'; // Applying the polyfill for URL from lib.dom
// if (typeof BigInt === 'undefined') global.BigInt = require('big-integer')
import {registerRootComponent} from 'expo';

Expand Down
80 changes: 42 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"dependencies": {
"@astronautlabs/jsonpath": "^1.1.2",
"@ethersproject/shims": "^5.7.0",
"react-native-dotenv": "^3.4.9",
"@react-native-async-storage/async-storage": "1.17.11",
"@react-native-community/blur": "^4.3.0",
"@react-native-community/hooks": "^3.0.0",
Expand All @@ -39,28 +40,32 @@
"@react-navigation/stack": "^6.3.20",
"@reduxjs/toolkit": "^1.9.3",
"@scure/base": "^1.1.3",
"@sphereon/did-auth-siop": "0.5.0-unstable.7",
"@sphereon/did-auth-siop": "0.6.0-unstable.9",
"@sphereon/isomorphic-webcrypto": "2.4.0-unstable.4",
"@sphereon/oid4vci-client": "0.7.3",
"@sphereon/oid4vci-common": "0.7.3",
"@sphereon/pex": "2.2.1-unstable.0",
"@sphereon/pex-models": "^2.1.1",
"@sphereon/oid4vci-client": "0.8.2-next.88",
"@sphereon/oid4vci-common": "0.8.2-next.88",
"@sphereon/pex": "3.2.1-unstable.7",
"@sphereon/pex-models": "^2.2.0",
"@sphereon/react-native-argon2": "2.0.9",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.15.0",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.15.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.15.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.15.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.15.0",
"@sphereon/ssi-sdk.contact-manager": "0.18.2-next.9",
"@sphereon/ssi-sdk.core": "0.18.2-next.9",
"@sphereon/ssi-sdk.data-store": "0.18.2-next.9",
"@sphereon/ssi-sdk.issuance-branding": "0.18.2-next.9",
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.18.2-next.9",
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.18.2-next.9",
"@sphereon/ssi-types": "0.18.2-next.9",
"@sphereon/ssi-sdk.event-logger": "0.18.2-next.9",
"@sphereon/ui-components.core": "0.1.3-unstable.88",
"@sphereon/ui-components.ssi-react-native": "0.1.3-unstable.88",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.16.1-next.2",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.16.1-next.2",
"@sphereon/ssi-sdk-ext.did-provider-key": "0.16.1-next.2",
"@sphereon/ssi-sdk-ext.did-resolver-key": "0.16.1-next.2",
"@sphereon/ssi-sdk-ext.did-resolver-ebsi": "0.16.1-next.2",
"@sphereon/ssi-sdk-ext.did-utils": "0.16.1-next.2",
"@sphereon/ssi-sdk-ext.key-manager": "0.16.1-next.2",
"@sphereon/ssi-sdk-ext.kms-local": "0.16.1-next.2",
"@sphereon/ssi-sdk.contact-manager": "0.18.2-unstable.61",
"@sphereon/ssi-sdk.core": "0.18.2-unstable.61",
"@sphereon/ssi-sdk.data-store": "0.18.2-unstable.61",
"@sphereon/ssi-sdk.issuance-branding": "0.18.2-unstable.61",
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.18.2-unstable.61",
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.18.2-unstable.61",
"@sphereon/ssi-sdk.event-logger": "0.18.2-unstable.61",
"@sphereon/ssi-sdk.oid4vci-holder": "0.18.2-unstable.61",
"@sphereon/ssi-types": "0.18.2-unstable.61",
"@sphereon/ui-components.core": "0.1.3-unstable.104",
"@sphereon/ui-components.ssi-react-native": "0.1.3-unstable.104",
"@transmute/lds-ecdsa-secp256k1-recovery2020": "^0.0.7",
"@veramo/core": "4.2.0",
"@veramo/credential-w3c": "4.2.0",
Expand All @@ -73,7 +78,6 @@
"@veramo/did-resolver": "4.2.0",
"@veramo/kms-local": "4.2.0",
"@veramo/utils": "4.2.0",
"@veramo/remote-client": "4.2.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"assert": "^1.1.1",
Expand Down Expand Up @@ -112,14 +116,14 @@
"react-native-camera": "^4.2.1",
"react-native-fast-image": "^8.6.3",
"react-native-fingerprint-scanner": "git+https://github.com/hieuvp/react-native-fingerprint-scanner.git",
"react-native-navigation-bar-color": "^2.0.2",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "~2.9.0",
"react-native-get-random-values": "1.8.0",
"react-native-gradle-plugin": "^0.71.19",
"react-native-json-tree": "^1.3.0",
"react-native-level-fs": "^3.0.1",
"react-native-material-ripple": "^0.9.1",
"react-native-navigation-bar-color": "^2.0.2",
"react-native-os": "^1.2.6",
"react-native-pager-view": "6.1.2",
"react-native-permissions": "^3.7.3",
Expand All @@ -146,22 +150,22 @@
"redux": "^4.1.1",
"redux-thunk": "^2.3.0",
"reflect-metadata": "^0.1.13",
"sqlite3": "^5.1.6",
"stream-browserify": "^3.0.0",
"styled-components": "^5.3.3",
"text-encoding": "^0.7.0",
"typeorm": "0.3.17",
"uint8arrays": "^3.1.1",
"vm-browserify": "^1.1.2",
"web-did-resolver": "^2.0.23",
"xstate": "^4.38.2"
"xstate": "^4.38.2",
"sqlite3": "^5.1.6"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/plugin-syntax-bigint": "^7.8.3",
"@babel/plugin-syntax-import-assertions": "^7.18.6",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-transform-flow-strip-types": "^7.18.9",
"@babel/preset-env": "^7.1.6",
"@babel/runtime": "^7.20.0",
Expand Down Expand Up @@ -242,18 +246,18 @@
"**/expo-random": "~13.1.1",
"ajv": "^8.12.0",
"@sphereon/isomorphic-argon2": "1.0.1",
"@sphereon/did-auth-siop": "0.5.0-unstable.7",
"@sphereon/ssi-types": "0.18.2-next.9",
"@sphereon/ssi-sdk.core": "0.18.2-next.9",
"@sphereon/ssi-sdk.data-store": "0.18.2-next.9",
"@sphereon/ssi-sdk.contact-manager": "0.18.2-next.9",
"@sphereon/ssi-sdk-ext.did-utils": "0.15.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.15.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.15.0",
"@sphereon/oid4vci-client": "0.7.3",
"@sphereon/oid4vci-common": "0.7.3",
"@sphereon/pex": "2.2.1-unstable.0",
"@sphereon/pex-models": "2.1.1",
"@sphereon/did-auth-siop": "0.6.0-unstable.9",
"@sphereon/ssi-types": "0.18.2-unstable.51",
"@sphereon/ssi-sdk.core": "0.18.2-unstable.51",
"@sphereon/ssi-sdk-ext.did-utils": "0.16.1-next.2",
"@sphereon/ssi-sdk-ext.kms-local": "0.16.1-next.2",
"@sphereon/ssi-sdk-ext.key-manager": "0.16.1-next.2",
"@sphereon/ssi-sdk.data-store": "0.18.2-unstable.51",
"@sphereon/ssi-sdk.contact-manager": "0.18.2-unstable.51",
"@sphereon/oid4vci-client": "0.8.2-next.88",
"@sphereon/oid4vci-common": "0.8.2-next.88",
"@sphereon/pex": "3.2.1-unstable.7",
"@sphereon/pex-models": "2.2.0",
"@mattrglobal/bbs-signatures": "npm:@animo-id/react-native-bbs-signatures@^0.1.0",
"@veramo/core": "4.2.0",
"@veramo/credential-w3c": "4.2.0",
Expand Down
78 changes: 78 additions & 0 deletions patches/@veramo+credential-w3c+4.2.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
diff --git a/node_modules/@veramo/credential-w3c/build/action-handler.js b/node_modules/@veramo/credential-w3c/build/action-handler.js
index d941dae..7a5ee6c 100644
--- a/node_modules/@veramo/credential-w3c/build/action-handler.js
+++ b/node_modules/@veramo/credential-w3c/build/action-handler.js
@@ -87,7 +87,7 @@ class CredentialPlugin {
throw new Error('invalid_argument: presentation.holder must be a DID managed by this agent');
}
//FIXME: `args` should allow picking a key or key type
- const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Ed25519');
+ const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Secp256r1' || k.type === 'Ed25519');
if (!key)
throw Error('key_not_found: No signing key for ' + identifier.did);
let verifiablePresentation;
@@ -117,6 +117,8 @@ class CredentialPlugin {
let alg = 'ES256K';
if (key.type === 'Ed25519') {
alg = 'EdDSA';
+ } else if (key.type === 'Secp256r1') {
+ alg = 'ES256';
}
const signer = wrapSigner(context, key, alg);
const jwt = yield (0, did_jwt_vc_1.createVerifiablePresentationJwt)(presentation, { did: identifier.did, signer, alg }, Object.assign({ removeOriginalFields, challenge, domain }, otherOptions));
@@ -174,13 +176,15 @@ class CredentialPlugin {
}
else {
//FIXME: `args` should allow picking a key or key type
- const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Ed25519');
+ const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Secp256r1' || k.type === 'Ed25519');
if (!key)
throw Error('No signing key for ' + identifier.did);
debug('Signing VC with', identifier.did);
let alg = 'ES256K';
if (key.type === 'Ed25519') {
alg = 'EdDSA';
+ } else if (key.type === 'Secp256r1') {
+ alg = 'ES256';
}
const signer = wrapSigner(context, key, alg);
const jwt = yield (0, did_jwt_vc_1.createVerifiableCredentialJwt)(credential, { did: identifier.did, signer, alg }, Object.assign({ removeOriginalFields }, otherOptions));
diff --git a/node_modules/@veramo/credential-w3c/src/action-handler.ts b/node_modules/@veramo/credential-w3c/src/action-handler.ts
index ca8d51b..6a9c032 100644
--- a/node_modules/@veramo/credential-w3c/src/action-handler.ts
+++ b/node_modules/@veramo/credential-w3c/src/action-handler.ts
@@ -129,7 +129,7 @@ export class CredentialPlugin implements IAgentPlugin {
throw new Error('invalid_argument: presentation.holder must be a DID managed by this agent')
}
//FIXME: `args` should allow picking a key or key type
- const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Ed25519')
+ const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Secp256r1' || k.type === 'Ed25519')
if (!key) throw Error('key_not_found: No signing key for ' + identifier.did)

let verifiablePresentation: VerifiablePresentation
@@ -164,6 +164,8 @@ export class CredentialPlugin implements IAgentPlugin {
let alg = 'ES256K'
if (key.type === 'Ed25519') {
alg = 'EdDSA'
+ } else if (key.type === 'Secp256r1') {
+ alg = 'ES256';
}
const signer = wrapSigner(context, key, alg)

@@ -235,13 +237,15 @@ export class CredentialPlugin implements IAgentPlugin {
}
} else {
//FIXME: `args` should allow picking a key or key type
- const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Ed25519')
+ const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Secp256r1' || k.type === 'Ed25519')
if (!key) throw Error('No signing key for ' + identifier.did)

debug('Signing VC with', identifier.did)
let alg = 'ES256K'
if (key.type === 'Ed25519') {
alg = 'EdDSA'
+ } else if (key.type === 'Secp256r1') {
+ alg = 'ES256';
}
const signer = wrapSigner(context, key, alg)
const jwt = await createVerifiableCredentialJwt(
20 changes: 18 additions & 2 deletions shim.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {DEBUG} from '@env';
if (typeof __dirname === 'undefined') global.__dirname = '/';
if (typeof __filename === 'undefined') global.__filename = '';
if (typeof process === 'undefined') {
Expand All @@ -10,15 +11,30 @@ if (typeof process === 'undefined') {
}
}
}
const debug = require('debug');

process.browser = false;
if (typeof Buffer === 'undefined') global.Buffer = require('buffer').Buffer;

// global.location = global.location || { port: 80 }
const isDev = typeof __DEV__ === 'boolean' && __DEV__;
process.env['NODE_ENV'] = isDev ? 'development' : 'production';
if (typeof localStorage !== 'undefined') {
localStorage.debug = isDev ? '*' : '';
const level = isDev ? DEBUG ?? '*' : '';
if (typeof window !== 'undefined') {
// @ts-ignore
process.type = 'renderer';
// @ts-ignore
window.localStorage = {
debug: level,
getItem: () => {
return level;
},
};
}

if (isDev) {
debug.log = console.info.bind(console);
debug.enable(level);
}

// If using the crypto shim, uncomment the following line to ensure
Expand Down
4 changes: 2 additions & 2 deletions src/@config/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DataStoreEntities, DataStoreMigrations} from '@sphereon/ssi-sdk.data-store';
import {DataStoreContactEntities, DataStoreIssuanceBrandingEntities, DataStoreMigrations} from '@sphereon/ssi-sdk.data-store';
import {Entities as VeramoDataStoreEntities, migrations as VeramoDataStoreMigrations} from '@veramo/data-store';
import * as driver from 'expo-sqlite';
import {ExpoConnectionOptions} from 'typeorm/driver/expo/ExpoConnectionOptions';
Expand All @@ -10,7 +10,7 @@ const sqliteConfig: ExpoConnectionOptions = {
type: 'expo',
database: 'sphereon-wallet.sqlite',
driver,
entities: [...VeramoDataStoreEntities, ...DataStoreEntities],
entities: [...VeramoDataStoreEntities, ...DataStoreContactEntities, ...DataStoreIssuanceBrandingEntities],
migrations: [...VeramoDataStoreMigrations, ...DataStoreMigrations],
migrationsRun: false, // We run migrations from code to ensure proper ordering with Redux
synchronize: false, // We do not enable synchronize, as we use migrations from code
Expand Down
Loading

0 comments on commit bcb5f45

Please sign in to comment.