mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 05:27:57 -05:00
[INJIMOB-2471] set UUID as vc identifier (#1745)
* [INJIMOB-2471] make identifier of Vc as random UUID Previously, we were relying on the id feild of the Vc to construct the unique identifier for VC component and file name for storing VC, this identifier in now replaced with random generated UUID. This was made since id property of VC is optional field as per w3c data-model 1.1. We are using UUID version 4 to ensure randomness and collision-resistance. Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2471] maintain consistency in setting VCMetadata ID Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJICERT-2471] use VC metadata id as VC key This VC key will be used for storing file name, component key & other identifier for VCs Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2471] remove setting identifier field in credential wrapper The identitifier in credentialWrapper having the value "$issuer:$protocol:$UUID" was used to construct VC metadata id, issuer and protocol field which is already available in context param. This is now replaced with constructing VC metadata with the required fields available in machine context. Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2471] use context VCMetadata instead of calling function for accessing in issuersMachine Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2471] optimize import Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> --------- Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>
This commit is contained in:
committed by
GitHub
parent
b30cd6b809
commit
82740bcc36
14
.talismanrc
14
.talismanrc
@@ -2,7 +2,7 @@ fileignoreconfig:
|
||||
- filename: package.json
|
||||
checksum: 5b4fcb5ddc7cc96cc2d1733b544d56ea66e88cdab995a1052fbf9ac0e9c2dc21
|
||||
- filename: package-lock.json
|
||||
checksum: e448b633936de692ebdbadfac3a5a1ae3c2a2a55a8cc3ea7440bd5ec1dd9cef5
|
||||
checksum: 8925d62a7011241371e295553f7bbe1af468c7f3f4d051436a30c8885a12d0a5
|
||||
- filename: lib/jsonld-signatures/suites/ed255192018/ed25519.ts
|
||||
checksum: 493b6e31144116cb612c24d98b97d8adcad5609c0a52c865a6847ced0a0ddc3a
|
||||
- filename: components/PasscodeVerify.tsx
|
||||
@@ -156,7 +156,7 @@ fileignoreconfig:
|
||||
- filename: injitest/README.md
|
||||
checksum: 82974a6b9363512472272245e9b433f92e63377e58ba306980876b745181a09c
|
||||
- filename: shared/VCMetadata.ts
|
||||
checksum: 4c0f2acc58894e5a427e1317b38d04daff91f64d1e61d6ee2f246ee516ef97ca
|
||||
checksum: c76bd3c825931ac241d8e4f76b8a7444789f49e3b4e45a599b4dcd574f7971c8
|
||||
- filename: ios/Podfile.lock
|
||||
checksum: 43bd4742f2ba13357d8b9c44430bfa3cca0bf9bf8341984fd81174a929c85955
|
||||
- filename: components/BackupAndRestoreBannerNotification.tsx
|
||||
@@ -268,7 +268,7 @@ fileignoreconfig:
|
||||
- filename: machines/Issuers/IssuersGuards.ts
|
||||
checksum: 21783a057207ad04facdb4c71884f49b0230490def04158419d730e0cc60eb83
|
||||
- filename: machines/Issuers/IssuersActions.ts
|
||||
checksum: 4414aa10588d2305293b1902982c5969895c858355e4b91d01dfaa8601c2dd62
|
||||
checksum: 03949a8a7f66f9b94a57b6b817b6c425e8438a7c796d75c00692d030342102b1
|
||||
- filename: injitest/automation_trigger.sh
|
||||
checksum: f2f34839c99cb1b871dde17aed8508a071345d22738796e005ff709d2dab8644
|
||||
- filename: machines/Issuers/IssuersService.ts
|
||||
@@ -344,7 +344,7 @@ fileignoreconfig:
|
||||
checksum: e1814f6ac8fe15794f26e96de887bc196ffcb37b434d46ffb69a9497d2683667
|
||||
- filename: injitest/src/main/resources/Vids.json
|
||||
checksum: 8bcffed7a6dd565ae695e1b29de0655e10bd5c5420af2718defd593a687b8817
|
||||
- filename: injitest/src/main/java/inji/utils/UpdateNetworkSettings.java
|
||||
- filename: injitest/src/main/java/inji/utils/UpdateNetworkSettings.java
|
||||
checksum: e249ce3e6b7f47abc183fe5a3637bb39ccb06900ef75b9b2f08426d1535e22aa
|
||||
- filename: App.tsx
|
||||
checksum: d16d4a40b246abe25a5d2da7ec65163b5756fe8ba9390608a7fc7f8e721b2ed1
|
||||
@@ -358,8 +358,8 @@ fileignoreconfig:
|
||||
checksum: c91348eceec5edbffa03ba03f3f52a8e90ff7f942816c9609080d1647052fd66
|
||||
- filename: ios/RNPixelpassModule.swift
|
||||
checksum: 822a2421798d5c0669f4ab1b983194eb770cbef2aa30bf212d06bd959738c4ca
|
||||
- filename: injitest/src/test/java/androidTestCases/VerifyHistoryTest.java
|
||||
checksum: dffc4741b251b42c81d5bdac7d649c02b37bb9045285590b29f86c2d5f526fd1
|
||||
- filename: injitest/src/test/java/androidTestCases/VerifyHistoryTest.java
|
||||
checksum: dffc4741b251b42c81d5bdac7d649c02b37bb9045285590b29f86c2d5f526fd1
|
||||
- filename: android/app/src/main/java/io/mosip/residentapp/RNPixelpassModule.java
|
||||
checksum: cef9be4bfafb54e2c885b2459f2819554cad6448b5dc372976706894df704e5d
|
||||
- filename: android/app/src/main/AndroidManifest.xml
|
||||
@@ -372,7 +372,7 @@ fileignoreconfig:
|
||||
checksum: 947b6d75543e2bf959ca2d95dd7224051e0b4ec2c28f7515f923701e22a932f0
|
||||
- filename: components/FaceScanner/LivenessDetection.tsx
|
||||
checksum: d4140a42ee9ca0f7c90e490f762d181a723fd9dd20db891cbbe53bfbd8f81632
|
||||
- filename: machines/VerifiableCredential/VCItemMachine/VCItemActions.ts
|
||||
- filename: machines/VerifiableCredential/VCItemMachine/VCItemActions.ts
|
||||
checksum: bc11e275227ccf93c5e869b47bb2b63454758983b8fc0e105004fefa1b169091
|
||||
- filename: machines/app.ts
|
||||
checksum: 5da59bb384d04e29c7745d773108903fa144275c57edc1aca1898fcae7baea84
|
||||
|
||||
@@ -155,11 +155,7 @@ export const IssuersActions = (model: any) => {
|
||||
},
|
||||
|
||||
storeVerifiableCredentialMeta: send(
|
||||
context =>
|
||||
StoreEvents.PREPEND(
|
||||
MY_VCS_STORE_KEY,
|
||||
getVCMetadata(context, context.keyType),
|
||||
),
|
||||
context => StoreEvents.PREPEND(MY_VCS_STORE_KEY, context.vcMetadata),
|
||||
{
|
||||
to: (context: any) => context.serviceRefs.store,
|
||||
},
|
||||
@@ -180,7 +176,7 @@ export const IssuersActions = (model: any) => {
|
||||
|
||||
storeVerifiableCredentialData: send(
|
||||
(context: any) => {
|
||||
const vcMetadata = getVCMetadata(context, context.keyType);
|
||||
const vcMetadata = context.vcMetadata;
|
||||
const {
|
||||
verifiableCredential: {
|
||||
processedCredential,
|
||||
@@ -206,7 +202,7 @@ export const IssuersActions = (model: any) => {
|
||||
context => {
|
||||
return {
|
||||
type: 'VC_ADDED',
|
||||
vcMetadata: getVCMetadata(context, context.keyType),
|
||||
vcMetadata: context.vcMetadata,
|
||||
};
|
||||
},
|
||||
{
|
||||
@@ -218,7 +214,7 @@ export const IssuersActions = (model: any) => {
|
||||
(context: any) => {
|
||||
return {
|
||||
type: 'VC_DOWNLOADED',
|
||||
vcMetadata: getVCMetadata(context, context.keyType),
|
||||
vcMetadata: context.vcMetadata,
|
||||
vc: context.credentialWrapper,
|
||||
};
|
||||
},
|
||||
@@ -293,7 +289,7 @@ export const IssuersActions = (model: any) => {
|
||||
|
||||
logDownloaded: send(
|
||||
context => {
|
||||
const vcMetadata = getVCMetadata(context, context.keyType);
|
||||
const vcMetadata = context.vcMetadata;
|
||||
return ActivityLogEvents.LOG_ACTIVITY(
|
||||
VCActivityLog.getLogFromObject({
|
||||
_vcKey: vcMetadata.getVcKey(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {assign, send} from 'xstate';
|
||||
import {CommunicationDetails} from '../../../shared/Utils';
|
||||
import {CommunicationDetails, UUID} from '../../../shared/Utils';
|
||||
import {StoreEvents} from '../../store';
|
||||
import {VCMetadata} from '../../../shared/VCMetadata';
|
||||
import {MIMOTO_BASE_URL, MY_VCS_STORE_KEY} from '../../../shared/constants';
|
||||
@@ -124,11 +124,8 @@ export const VCItemActions = model => {
|
||||
setContext: model.assign((context, event) => {
|
||||
const vcMetadata = VCMetadata.fromVC(context.vcMetadata);
|
||||
if (!vcMetadata.id) {
|
||||
const verifiableCredentialId = event.response.verifiableCredential.id;
|
||||
const credId = verifiableCredentialId.startsWith('did')
|
||||
? verifiableCredentialId.split(':')
|
||||
: verifiableCredentialId.split('/');
|
||||
vcMetadata.id = `${credId[credId.length - 1]} - ${vcMetadata.issuer}`;
|
||||
const credId = UUID.generate();
|
||||
vcMetadata.id = `${credId}_${vcMetadata.issuer}`;
|
||||
}
|
||||
return {
|
||||
...context,
|
||||
|
||||
@@ -43,22 +43,24 @@ export interface CredentialSubject {
|
||||
|
||||
type VCContext = (string | Record<string, unknown>)[];
|
||||
|
||||
export type Credential = {
|
||||
credentialConfigurationId: any;
|
||||
'@context': VCContext;
|
||||
credentialSubject: CredentialSubject;
|
||||
id: string;
|
||||
issuanceDate: string;
|
||||
issuer: string;
|
||||
proof: {
|
||||
created: string;
|
||||
jws: string;
|
||||
proofPurpose: 'assertionMethod' | string;
|
||||
type: 'RsaSignature2018' | string;
|
||||
verificationMethod: string;
|
||||
};
|
||||
type: string[];
|
||||
} | string
|
||||
export type Credential =
|
||||
| {
|
||||
credentialConfigurationId: any;
|
||||
'@context': VCContext;
|
||||
credentialSubject: CredentialSubject;
|
||||
id: string;
|
||||
issuanceDate: string;
|
||||
issuer: string;
|
||||
proof: {
|
||||
created: string;
|
||||
jws: string;
|
||||
proofPurpose: 'assertionMethod' | string;
|
||||
type: 'RsaSignature2018' | string;
|
||||
verificationMethod: string;
|
||||
};
|
||||
type: string[];
|
||||
}
|
||||
| string;
|
||||
|
||||
export interface VerifiableCredential {
|
||||
issuerLogo: logoType;
|
||||
@@ -81,7 +83,6 @@ export interface VerifiableCredentialData {
|
||||
export interface CredentialWrapper {
|
||||
verifiableCredential: VerifiableCredential;
|
||||
format: string;
|
||||
identifier: string;
|
||||
generatedOn: Date;
|
||||
vcMetadata: VCMetadata;
|
||||
}
|
||||
|
||||
100
package-lock.json
generated
100
package-lock.json
generated
@@ -100,6 +100,7 @@
|
||||
"simple-pem2jwk": "^0.2.4",
|
||||
"telemetry-sdk": "git://github.com/mosip/sunbird-telemetry-sdk.git#f762be5732ee552c0c70bdd540aa4e2701554c71",
|
||||
"text-encoding": "^0.7.0",
|
||||
"uuid": "^11.0.3",
|
||||
"xstate": "^4.35.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -14126,6 +14127,16 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-auth-session/node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-barcode-scanner": {
|
||||
"version": "12.3.2",
|
||||
"resolved": "https://registry.npmjs.org/expo-barcode-scanner/-/expo-barcode-scanner-12.3.2.tgz",
|
||||
@@ -14161,6 +14172,16 @@
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-constants/node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-crypto": {
|
||||
"version": "12.6.0",
|
||||
"resolved": "https://registry.npmjs.org/expo-crypto/-/expo-crypto-12.6.0.tgz",
|
||||
@@ -14196,6 +14217,16 @@
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-file-system/node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-font": {
|
||||
"version": "11.1.1",
|
||||
"resolved": "https://registry.npmjs.org/expo-font/-/expo-font-11.1.1.tgz",
|
||||
@@ -14397,6 +14428,16 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-linking/node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-local-authentication": {
|
||||
"version": "13.3.0",
|
||||
"resolved": "https://registry.npmjs.org/expo-local-authentication/-/expo-local-authentication-13.3.0.tgz",
|
||||
@@ -14880,6 +14921,16 @@
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/expo/node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/extend": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
||||
@@ -29274,12 +29325,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"version": "11.0.3",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.3.tgz",
|
||||
"integrity": "sha512-d0z310fCWv5dJwnX1Y/MncBAqGMKEzlBb1AOf7z9K8ALnd0utBX/msg/fA0+sbyN1ihbMsLhrBlnl1ak7Wa0rg==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa",
|
||||
"https://github.com/sponsors/ctavan"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
"uuid": "dist/esm/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/v8-to-istanbul": {
|
||||
@@ -40399,6 +40454,11 @@
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
|
||||
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw=="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -40561,6 +40621,11 @@
|
||||
"requires": {
|
||||
"has-flag": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -40587,6 +40652,13 @@
|
||||
"requires": {
|
||||
"@expo/config": "~8.1.0",
|
||||
"uuid": "^3.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"expo-crypto": {
|
||||
@@ -40614,6 +40686,13 @@
|
||||
"integrity": "sha512-xy61KaTaDgXhT/dllwYDHm3ch026EyO8j4eC6wSVr/yE12MMMxAC09yGwy4f7kkOs6ztGVQF5j7ldRzNLN4l0Q==",
|
||||
"requires": {
|
||||
"uuid": "^3.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"expo-font": {
|
||||
@@ -40773,6 +40852,11 @@
|
||||
"requires": {
|
||||
"has-flag": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -51856,9 +51940,9 @@
|
||||
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
||||
"version": "11.0.3",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-11.0.3.tgz",
|
||||
"integrity": "sha512-d0z310fCWv5dJwnX1Y/MncBAqGMKEzlBb1AOf7z9K8ALnd0utBX/msg/fA0+sbyN1ihbMsLhrBlnl1ak7Wa0rg=="
|
||||
},
|
||||
"v8-to-istanbul": {
|
||||
"version": "9.1.0",
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
"simple-pem2jwk": "^0.2.4",
|
||||
"telemetry-sdk": "git://github.com/mosip/sunbird-telemetry-sdk.git#f762be5732ee552c0c70bdd540aa4e2701554c71",
|
||||
"text-encoding": "^0.7.0",
|
||||
"uuid": "^11.0.3",
|
||||
"xstate": "^4.35.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { VCMetadata } from './VCMetadata';
|
||||
import { NETWORK_REQUEST_FAILED } from './constants';
|
||||
import { groupBy } from './javascript';
|
||||
import { Issuers } from './openId4VCI/Utils';
|
||||
import {VCMetadata} from './VCMetadata';
|
||||
import {NETWORK_REQUEST_FAILED} from './constants';
|
||||
import {groupBy} from './javascript';
|
||||
import {Issuers} from './openId4VCI/Utils';
|
||||
import {v4 as uuid} from 'uuid';
|
||||
|
||||
export const getVCsOrderedByPinStatus = (vcMetadatas: VCMetadata[]) => {
|
||||
const [pinned, unpinned] = groupBy(
|
||||
@@ -54,3 +55,9 @@ export const parseJSON = (input: any) => {
|
||||
export const isNetworkError = (error: string) => {
|
||||
return error.includes(NETWORK_REQUEST_FAILED);
|
||||
};
|
||||
|
||||
export class UUID {
|
||||
public static generate(): string {
|
||||
return uuid();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
Credential,
|
||||
CredentialTypes,
|
||||
VC,
|
||||
VcIdType,
|
||||
VerifiableCredential,
|
||||
@@ -8,12 +7,17 @@ import {
|
||||
import {Protocols} from './openId4VCI/Utils';
|
||||
import {getMosipIdentifier} from './commonUtil';
|
||||
import {VCFormat} from './VCFormat';
|
||||
import {isMosipVC} from './Utils';
|
||||
import {isMosipVC, UUID} from './Utils';
|
||||
import {getCredentialType} from '../components/VC/common/VCUtils';
|
||||
|
||||
const VC_KEY_PREFIX = 'VC';
|
||||
const VC_ITEM_STORE_KEY_REGEX = '^VC_[a-zA-Z0-9_-]+$';
|
||||
|
||||
/** TODO: two identifiers requestId and id
|
||||
* we have 2 fields in metadata - id, requestID
|
||||
* requestID -> This will be holding the requestId required for OTP flow VCs and for OIDC flow it holds the generated UUID
|
||||
* id -> holds UUID for both OTP based & OIDC flow
|
||||
*/
|
||||
export class VCMetadata {
|
||||
static vcKeyRegExp = new RegExp(VC_ITEM_STORE_KEY_REGEX);
|
||||
idType: VcIdType | string = '';
|
||||
@@ -111,8 +115,8 @@ export class VCMetadata {
|
||||
// Update VC_ITEM_STORE_KEY_REGEX in case of changes in vckey
|
||||
getVcKey(): string {
|
||||
return this.timestamp !== ''
|
||||
? `${VC_KEY_PREFIX}_${this.timestamp}_${this.requestId}`
|
||||
: `${VC_KEY_PREFIX}_${this.requestId}`;
|
||||
? `${VC_KEY_PREFIX}_${this.timestamp}_${this.id}`
|
||||
: `${VC_KEY_PREFIX}_${this.id}`;
|
||||
}
|
||||
|
||||
equals(other: VCMetadata): boolean {
|
||||
@@ -124,19 +128,15 @@ export function parseMetadatas(metadataStrings: object[]) {
|
||||
return metadataStrings.map(o => new VCMetadata(o));
|
||||
}
|
||||
|
||||
export const getVCMetadata = (
|
||||
context: object,
|
||||
keyType: string,
|
||||
credType: CredentialTypes,
|
||||
) => {
|
||||
const [issuer, protocol, credentialId] =
|
||||
context.credentialWrapper?.identifier.split(':');
|
||||
export const getVCMetadata = (context: object, keyType: string) => {
|
||||
const issuer = context.selectedIssuer.credential_issuer;
|
||||
const credentialId = `${UUID.generate()}_${issuer}`;
|
||||
|
||||
return VCMetadata.fromVC({
|
||||
requestId: credentialId ?? null,
|
||||
requestId: credentialId,
|
||||
issuer: issuer,
|
||||
protocol: protocol,
|
||||
id: `${credentialId} + '_' + ${issuer}`,
|
||||
protocol: context.selectedIssuer.protocol,
|
||||
id: credentialId,
|
||||
timestamp: context.timestamp ?? '',
|
||||
isVerified: context.vcMetadata.isVerified ?? false,
|
||||
isExpired: context.vcMetadata.isExpired ?? false,
|
||||
|
||||
@@ -2,34 +2,39 @@ import base64url from 'base64url';
|
||||
import i18next from 'i18next';
|
||||
import jwtDecode from 'jwt-decode';
|
||||
import jose from 'node-jose';
|
||||
import { NativeModules } from 'react-native';
|
||||
import { vcVerificationBannerDetails } from '../../components/BannerNotificationContainer';
|
||||
import { VCProcessor } from '../../components/VC/common/VCProcessor';
|
||||
import {NativeModules} from 'react-native';
|
||||
import {vcVerificationBannerDetails} from '../../components/BannerNotificationContainer';
|
||||
import {VCProcessor} from '../../components/VC/common/VCProcessor';
|
||||
import {
|
||||
BOTTOM_SECTION_FIELDS_WITH_DETAILED_ADDRESS_FIELDS,
|
||||
DETAIL_VIEW_ADD_ON_FIELDS,
|
||||
getCredentialTypeFromWellKnown,
|
||||
} from '../../components/VC/common/VCUtils';
|
||||
import i18n from '../../i18n';
|
||||
import { displayType, issuerType } from '../../machines/Issuers/IssuersMachine';
|
||||
import { getVerifiableCredential } from '../../machines/VerifiableCredential/VCItemMachine/VCItemSelectors';
|
||||
import {displayType, issuerType} from '../../machines/Issuers/IssuersMachine';
|
||||
import {
|
||||
Credential,
|
||||
CredentialTypes,
|
||||
CredentialWrapper,
|
||||
VerifiableCredential,
|
||||
} from '../../machines/VerifiableCredential/VCMetaMachine/vc';
|
||||
import getAllConfigurations, { CACHED_API } from '../api';
|
||||
import { isIOS } from '../constants';
|
||||
import { getJWT } from '../cryptoutil/cryptoUtil';
|
||||
import { KeyTypes } from '../cryptoutil/KeyTypes';
|
||||
import { UnsupportedVcFormat } from '../error/UnsupportedVCFormat';
|
||||
import { TelemetryConstants } from '../telemetry/TelemetryConstants';
|
||||
import { getErrorEventData, sendErrorEvent } from '../telemetry/TelemetryUtils';
|
||||
import { isMockVC } from '../Utils';
|
||||
import { VCFormat } from '../VCFormat';
|
||||
import { VerificationErrorMessage, VerificationErrorType, verifyCredential } from '../vcjs/verifyCredential';
|
||||
import { VCMetadata } from '../VCMetadata';
|
||||
import getAllConfigurations, {CACHED_API} from '../api';
|
||||
import {isIOS} from '../constants';
|
||||
import {getJWT} from '../cryptoutil/cryptoUtil';
|
||||
import {isMockVC} from '../Utils';
|
||||
import {
|
||||
VerificationErrorMessage,
|
||||
VerificationErrorType,
|
||||
verifyCredential,
|
||||
} from '../vcjs/verifyCredential';
|
||||
import {getVerifiableCredential} from '../../machines/VerifiableCredential/VCItemMachine/VCItemSelectors';
|
||||
import {getErrorEventData, sendErrorEvent} from '../telemetry/TelemetryUtils';
|
||||
import {TelemetryConstants} from '../telemetry/TelemetryConstants';
|
||||
import {KeyTypes} from '../cryptoutil/KeyTypes';
|
||||
import {VCFormat} from '../VCFormat';
|
||||
import {UnsupportedVcFormat} from '../error/UnsupportedVCFormat';
|
||||
import {VCMetadata} from '../VCMetadata';
|
||||
import {UUID} from '../Utils';
|
||||
|
||||
export const Protocols = {
|
||||
OpenId4VCI: 'OpenId4VCI',
|
||||
@@ -65,31 +70,6 @@ export const isActivationNeeded = (issuer: string) => {
|
||||
|
||||
export const Issuers_Key_Ref = 'OpenId4VCI_KeyPair';
|
||||
|
||||
export const getIdentifier = (
|
||||
context,
|
||||
credential: VerifiableCredential,
|
||||
format: string,
|
||||
) => {
|
||||
let credentialIdentifier = '';
|
||||
if (format === VCFormat.mso_mdoc) {
|
||||
credentialIdentifier = credential?.processedCredential?.['id'] ?? '';
|
||||
} else if (typeof credential.credential !== 'string') {
|
||||
credentialIdentifier = credential.credential.id;
|
||||
}
|
||||
const credId =
|
||||
credentialIdentifier.startsWith('did') ||
|
||||
credentialIdentifier.startsWith('urn:')
|
||||
? credentialIdentifier.split(':')
|
||||
: credentialIdentifier.split('/');
|
||||
return (
|
||||
context.selectedIssuer.issuer_id +
|
||||
':' +
|
||||
context.selectedIssuer.protocol +
|
||||
':' +
|
||||
credId[credId.length - 1]
|
||||
);
|
||||
};
|
||||
|
||||
export const updateCredentialInformation = async (
|
||||
context,
|
||||
credential: VerifiableCredential,
|
||||
@@ -113,11 +93,6 @@ export const updateCredentialInformation = async (
|
||||
return {
|
||||
verifiableCredential,
|
||||
format: context.selectedCredentialType.format,
|
||||
identifier: getIdentifier(
|
||||
context,
|
||||
verifiableCredential,
|
||||
context.selectedCredentialType.format,
|
||||
),
|
||||
generatedOn: new Date(),
|
||||
vcMetadata: {
|
||||
...context.vcMetadata,
|
||||
@@ -448,12 +423,14 @@ export function getMatchingCredentialIssuerMetadata(
|
||||
|
||||
export async function verifyCredentialData(
|
||||
credential: Credential,
|
||||
credentialFormat: string,
|
||||
issuerId: string
|
||||
credentialFormat: string,
|
||||
issuerId: string,
|
||||
) {
|
||||
|
||||
if (credentialFormat === VCFormat.mso_mdoc || !isMockVC(issuerId)) {
|
||||
const verificationResult = await verifyCredential(credential, credentialFormat);
|
||||
const verificationResult = await verifyCredential(
|
||||
credential,
|
||||
credentialFormat,
|
||||
);
|
||||
return verificationResult;
|
||||
} else {
|
||||
return {
|
||||
@@ -462,4 +439,4 @@ export async function verifyCredentialData(
|
||||
verificationErrorCode: VerificationErrorType.NO_ERROR,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user