@procivis/react-native-one-core 1.26730.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +202 -0
- package/android/build.gradle +96 -0
- package/android/proguard-rules.pro +4 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/ch/procivis/one/core/Deserialize.kt +118 -0
- package/android/src/main/java/ch/procivis/one/core/DeserializeSpecific.kt +94 -0
- package/android/src/main/java/ch/procivis/one/core/ProcivisOneCoreModule.kt +444 -0
- package/android/src/main/java/ch/procivis/one/core/ProcivisOneCorePackage.kt +19 -0
- package/android/src/main/java/ch/procivis/one/core/Serialize.kt +115 -0
- package/android/src/main/java/ch/procivis/one/core/SerializeSpecific.kt +121 -0
- package/android/src/main/java/ch/procivis/one/core/Util.kt +23 -0
- package/bin/postinstall +12 -0
- package/core-sdk.json +16 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +59 -0
- package/dist/src/backup.d.ts +22 -0
- package/dist/src/backup.js +1 -0
- package/dist/src/config.d.ts +100 -0
- package/dist/src/config.js +25 -0
- package/dist/src/core.d.ts +109 -0
- package/dist/src/core.js +11 -0
- package/dist/src/credential.d.ts +115 -0
- package/dist/src/credential.js +39 -0
- package/dist/src/credentialSchema.d.ts +130 -0
- package/dist/src/credentialSchema.js +37 -0
- package/dist/src/did.d.ts +59 -0
- package/dist/src/did.js +27 -0
- package/dist/src/error.d.ts +23 -0
- package/dist/src/error.js +25 -0
- package/dist/src/history.d.ts +66 -0
- package/dist/src/history.js +42 -0
- package/dist/src/key.d.ts +17 -0
- package/dist/src/key.js +1 -0
- package/dist/src/list.d.ts +14 -0
- package/dist/src/list.js +5 -0
- package/dist/src/proof.d.ts +137 -0
- package/dist/src/proof.js +30 -0
- package/dist/src/proofSchema.d.ts +106 -0
- package/dist/src/proofSchema.js +9 -0
- package/dist/src/trust.d.ts +46 -0
- package/dist/src/trust.js +18 -0
- package/ios/Deserialize.swift +655 -0
- package/ios/ProcivisOneCoreModule.m +216 -0
- package/ios/ProcivisOneCoreModule.swift +600 -0
- package/ios/ProcivisRNOneCore.xcodeproj/project.pbxproj +318 -0
- package/ios/Serialize.swift +607 -0
- package/ios/Util.swift +47 -0
- package/ios/react-native-one-core-Bridging-Header.h +1 -0
- package/package.json +40 -0
- package/react-native-one-core.podspec +46 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
package ch.procivis.one.core
|
|
2
|
+
|
|
3
|
+
import ch.procivis.one.core.Serialize.convertToRN
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.bridge.ReadableArray
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap
|
|
7
|
+
|
|
8
|
+
object SerializeSpecific {
|
|
9
|
+
object Obj {
|
|
10
|
+
private val CustomConversionTypes =
|
|
11
|
+
arrayOf(
|
|
12
|
+
HistoryMetadataBinding::class.java,
|
|
13
|
+
ClaimBindingDto::class.java,
|
|
14
|
+
ProofRequestClaimBindingDto::class.java,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
fun isCustomConversionType(input: Any?): Boolean {
|
|
18
|
+
for (customType in CustomConversionTypes) {
|
|
19
|
+
if (customType.isInstance(input)) {
|
|
20
|
+
return true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fun convertCustom(input: Any): ReadableMap {
|
|
27
|
+
if (input is HistoryMetadataBinding) {
|
|
28
|
+
return historyMetadata(input)
|
|
29
|
+
}
|
|
30
|
+
if (input is ClaimBindingDto) {
|
|
31
|
+
return claim(input)
|
|
32
|
+
}
|
|
33
|
+
if (input is ProofRequestClaimBindingDto) {
|
|
34
|
+
return proofClaim(input)
|
|
35
|
+
}
|
|
36
|
+
throw IllegalArgumentException("Invalid map conversion: $input")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private fun historyMetadata(metadata: HistoryMetadataBinding): ReadableMap {
|
|
40
|
+
when (metadata) {
|
|
41
|
+
is HistoryMetadataBinding.UnexportableEntities ->
|
|
42
|
+
return convertToRN(metadata.value) as ReadableMap
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private fun claim(c: ClaimBindingDto): ReadableMap {
|
|
47
|
+
val result = Arguments.createMap()
|
|
48
|
+
result.putString("id", c.id)
|
|
49
|
+
result.putString("key", c.key)
|
|
50
|
+
result.putString("dataType", c.dataType)
|
|
51
|
+
result.putBoolean("array", c.array)
|
|
52
|
+
|
|
53
|
+
when (val value = c.value) {
|
|
54
|
+
is ClaimValueBindingDto.Boolean -> result.putBoolean("value", value.value)
|
|
55
|
+
is ClaimValueBindingDto.Float -> result.putDouble("value", value.value)
|
|
56
|
+
is ClaimValueBindingDto.Integer -> result.putInt("value", value.value.toInt())
|
|
57
|
+
is ClaimValueBindingDto.String -> result.putString("value", value.value)
|
|
58
|
+
is ClaimValueBindingDto.Nested ->
|
|
59
|
+
result.putArray("value", convertToRN(value.value) as ReadableArray)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return result
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private fun proofClaim(c: ProofRequestClaimBindingDto): ReadableMap {
|
|
66
|
+
val result = Arguments.createMap()
|
|
67
|
+
result.putMap("schema", convertToRN(c.schema) as ReadableMap)
|
|
68
|
+
|
|
69
|
+
c.value?.let {
|
|
70
|
+
when (val value = it) {
|
|
71
|
+
is ProofRequestClaimValueBindingDto.Value ->
|
|
72
|
+
result.putString("value", value.value)
|
|
73
|
+
|
|
74
|
+
is ProofRequestClaimValueBindingDto.Claims ->
|
|
75
|
+
result.putArray("value", convertToRN(value.value) as ReadableArray)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return result
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
object Str {
|
|
84
|
+
private val CustomConversionTypes =
|
|
85
|
+
arrayOf(
|
|
86
|
+
CredentialSchemaTypeBindingEnum::class.java,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
fun isCustomConversionType(input: Any?): Boolean {
|
|
90
|
+
for (customType in CustomConversionTypes) {
|
|
91
|
+
if (customType.isInstance(input)) {
|
|
92
|
+
return true
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fun convertCustom(input: Any): String {
|
|
99
|
+
if (input is CredentialSchemaTypeBindingEnum) {
|
|
100
|
+
return credentialSchemaType(input)
|
|
101
|
+
}
|
|
102
|
+
throw IllegalArgumentException("Invalid string conversion: $input")
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private fun credentialSchemaType(type: CredentialSchemaTypeBindingEnum): String {
|
|
106
|
+
return when (type) {
|
|
107
|
+
is CredentialSchemaTypeBindingEnum.ProcivisOneSchema2024 ->
|
|
108
|
+
"PROCIVIS_ONE_SCHEMA2024"
|
|
109
|
+
|
|
110
|
+
is CredentialSchemaTypeBindingEnum.FallbackSchema2024 ->
|
|
111
|
+
"FALLBACK_SCHEMA2024"
|
|
112
|
+
|
|
113
|
+
is CredentialSchemaTypeBindingEnum.Mdoc ->
|
|
114
|
+
"MDOC"
|
|
115
|
+
|
|
116
|
+
is CredentialSchemaTypeBindingEnum.Other ->
|
|
117
|
+
type.value
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package ch.procivis.one.core
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
|
|
6
|
+
object Util {
|
|
7
|
+
// error handling
|
|
8
|
+
fun asyncCall(promise: Promise, function: () -> Any?) {
|
|
9
|
+
try {
|
|
10
|
+
promise.resolve(function())
|
|
11
|
+
} catch (error: Throwable) {
|
|
12
|
+
promise.reject(
|
|
13
|
+
error.javaClass.simpleName.replaceFirst(Regex("Exception$"), "Error"),
|
|
14
|
+
error.message,
|
|
15
|
+
error
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fun ReadableMap.getUInt(name: String): UInt? {
|
|
22
|
+
return if (this.hasKey(name) && !this.isNull(name)) this.getInt(name).toUInt() else null
|
|
23
|
+
}
|
package/bin/postinstall
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const childProcess = require('child_process');
|
|
3
|
+
|
|
4
|
+
if (fs.existsSync('node_modules/husky')) {
|
|
5
|
+
try {
|
|
6
|
+
childProcess.execSync('yarn husky install', {
|
|
7
|
+
stdio: 'inherit',
|
|
8
|
+
});
|
|
9
|
+
} catch (error) {
|
|
10
|
+
process.exit(error.status);
|
|
11
|
+
}
|
|
12
|
+
}
|
package/core-sdk.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"android": {
|
|
3
|
+
"debug": {
|
|
4
|
+
"url": "https://onetfstatestorage.blob.core.windows.net/core-sdk/android/26730/onecore-debug.aar",
|
|
5
|
+
"sha1": "5064f7c4f6ac8ef0e5105796b581868ec6cf8014"
|
|
6
|
+
},
|
|
7
|
+
"release": {
|
|
8
|
+
"url": "https://onetfstatestorage.blob.core.windows.net/core-sdk/android/26730/onecore-release.aar",
|
|
9
|
+
"sha1": "8fa14a6be6465f2161f32ac8bcbf703fbc48303a"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"ios": {
|
|
13
|
+
"url": "https://onetfstatestorage.blob.core.windows.net/core-sdk/ios/26730/deploy.zip",
|
|
14
|
+
"sha1": "d613c5848050444af33cdcf6b02ba9c6dce654c5"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ONECore } from "./src/core";
|
|
2
|
+
export * from "./src/core";
|
|
3
|
+
export * from "./src/error";
|
|
4
|
+
/**
|
|
5
|
+
* Initialize ONE Core for Holder
|
|
6
|
+
* @note Beware that only one instance can be initialized at a time, repeated calls will fail
|
|
7
|
+
* @returns ONE Core instance
|
|
8
|
+
*/
|
|
9
|
+
export declare function initializeHolderCore(): Promise<ONECore>;
|
|
10
|
+
/**
|
|
11
|
+
* Initialize ONE Core for Verifier
|
|
12
|
+
* @note Beware that only one instance can be initialized at a time, repeated calls will fail
|
|
13
|
+
* @returns ONE Core instance
|
|
14
|
+
*/
|
|
15
|
+
export declare function initializeVerifierCore(): Promise<ONECore>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { NativeModules } from "react-native";
|
|
2
|
+
import { OneError, OneErrorCode } from "./src/error";
|
|
3
|
+
export * from "./src/core";
|
|
4
|
+
export * from "./src/error";
|
|
5
|
+
const ONE = NativeModules.ProcivisOneCoreModule;
|
|
6
|
+
// Config entities are exposed as serialized JSON, here conversion to structs
|
|
7
|
+
const originalGetConfig = ONE.getConfig;
|
|
8
|
+
ONE.getConfig = () => originalGetConfig().then((config) => objectMap(config, (entities) => objectMap(entities, (json) => JSON.parse(json))));
|
|
9
|
+
/**
|
|
10
|
+
* Initialize ONE Core for Holder
|
|
11
|
+
* @note Beware that only one instance can be initialized at a time, repeated calls will fail
|
|
12
|
+
* @returns ONE Core instance
|
|
13
|
+
*/
|
|
14
|
+
export async function initializeHolderCore() {
|
|
15
|
+
await wrapFn(ONE.initializeHolder, "initializeHolderCore")();
|
|
16
|
+
return wrapObj(ONE);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Initialize ONE Core for Verifier
|
|
20
|
+
* @note Beware that only one instance can be initialized at a time, repeated calls will fail
|
|
21
|
+
* @returns ONE Core instance
|
|
22
|
+
*/
|
|
23
|
+
export async function initializeVerifierCore() {
|
|
24
|
+
await wrapFn(ONE.initializeVerifier, "initializeVerifierCore")();
|
|
25
|
+
return wrapObj(ONE);
|
|
26
|
+
}
|
|
27
|
+
// UTILS
|
|
28
|
+
// returns a new object with the values at each key mapped using fn(value)
|
|
29
|
+
const objectMap = (obj, fn) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, fn(v)]));
|
|
30
|
+
// Function call arguments/Error transformation
|
|
31
|
+
// for devs: Beware to not declare function parameters as optional, otherwise automatic conversion to null will not be performed
|
|
32
|
+
function wrapFn(fn, name) {
|
|
33
|
+
return (...args) => {
|
|
34
|
+
const errHandler = (cause) => {
|
|
35
|
+
const code = (cause ?? {}).code;
|
|
36
|
+
if (Object.values(OneErrorCode).includes(code)) {
|
|
37
|
+
// throw a specific error to be able to handle it easily
|
|
38
|
+
throw new OneError({
|
|
39
|
+
code,
|
|
40
|
+
cause,
|
|
41
|
+
message: cause?.message,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw cause;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
// set name on the err handler to display the original function name in callstack
|
|
49
|
+
Object.defineProperty(errHandler, "name", { value: name });
|
|
50
|
+
// convert undefined parameters to null for proper parameter matching in native code
|
|
51
|
+
return fn(...args.map((x) => (x === undefined ? null : x))).catch(errHandler);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function wrapObj(obj) {
|
|
55
|
+
return Object.entries(obj).reduce((aggr, [key, fn]) => ({
|
|
56
|
+
...aggr,
|
|
57
|
+
[key]: typeof fn === "function" ? wrapFn(fn, key) : fn,
|
|
58
|
+
}), {});
|
|
59
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CredentialDetail } from "./credential";
|
|
2
|
+
import { DidListItem } from "./did";
|
|
3
|
+
import { HistoryListItem } from "./history";
|
|
4
|
+
import { KeyListItem } from "./key";
|
|
5
|
+
export interface UnexportableEntities {
|
|
6
|
+
credentials: CredentialDetail[];
|
|
7
|
+
keys: KeyListItem[];
|
|
8
|
+
dids: DidListItem[];
|
|
9
|
+
totalCredentials: number;
|
|
10
|
+
totalKeys: number;
|
|
11
|
+
totalDids: number;
|
|
12
|
+
}
|
|
13
|
+
export interface BackupCreate {
|
|
14
|
+
historyId: HistoryListItem["id"];
|
|
15
|
+
file: string;
|
|
16
|
+
unexportable: UnexportableEntities;
|
|
17
|
+
}
|
|
18
|
+
export interface ImportBackupMetadata {
|
|
19
|
+
dbVersion: string;
|
|
20
|
+
dbHash: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export declare enum KeyStorageSecurityEnum {
|
|
2
|
+
HARDWARE = "HARDWARE",
|
|
3
|
+
SOFTWARE = "SOFTWARE"
|
|
4
|
+
}
|
|
5
|
+
export interface KeyStorageCapabilities {
|
|
6
|
+
algorithms: string[];
|
|
7
|
+
security: KeyStorageSecurityEnum[];
|
|
8
|
+
}
|
|
9
|
+
export interface DidCapabilities {
|
|
10
|
+
operations: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare enum FormatFeatureEnum {
|
|
13
|
+
SelectiveDisclosure = "SELECTIVE_DISCLOSURE",
|
|
14
|
+
SupportsCredentialDesign = "SUPPORTS_CREDENTIAL_DESIGN",
|
|
15
|
+
RequiresSchemaId = "REQUIRES_SCHEMA_ID"
|
|
16
|
+
}
|
|
17
|
+
export declare enum FormatSelectiveDisclosureEnum {
|
|
18
|
+
AnyLevel = "ANY_LEVEL",
|
|
19
|
+
SecondLevel = "SECOND_LEVEL"
|
|
20
|
+
}
|
|
21
|
+
export interface FormatCapabilities {
|
|
22
|
+
features: FormatFeatureEnum[];
|
|
23
|
+
selectiveDisclosure: FormatSelectiveDisclosureEnum[];
|
|
24
|
+
issuanceDidMethods: string[];
|
|
25
|
+
issuanceExchangeProtocols: string[];
|
|
26
|
+
proofExchangeProtocols: string[];
|
|
27
|
+
revocationMethods: string[];
|
|
28
|
+
signingKeyAlgorithms: string[];
|
|
29
|
+
verificationKeyAlgorithms: string[];
|
|
30
|
+
datatypes: Array<DataTypeEnum | string>;
|
|
31
|
+
allowedSchemaIds: string[];
|
|
32
|
+
forbiddenClaimNames: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface ConfigEntity<Capabilities> {
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
capabilities?: Capabilities;
|
|
37
|
+
display: string;
|
|
38
|
+
order: number;
|
|
39
|
+
}
|
|
40
|
+
export type ConfigEntities<Capabilities = undefined, Params = {
|
|
41
|
+
type: string;
|
|
42
|
+
}> = Record<string, ConfigEntity<Capabilities> & Params>;
|
|
43
|
+
export declare enum DataTypeEnum {
|
|
44
|
+
String = "STRING",
|
|
45
|
+
Number = "NUMBER",
|
|
46
|
+
Date = "DATE",
|
|
47
|
+
File = "FILE",
|
|
48
|
+
Boolean = "BOOLEAN",
|
|
49
|
+
Object = "OBJECT"
|
|
50
|
+
}
|
|
51
|
+
type DataTypeError = string | Record<string, string>;
|
|
52
|
+
export interface StringDataTypeParams {
|
|
53
|
+
autocomplete: boolean;
|
|
54
|
+
error?: DataTypeError;
|
|
55
|
+
pattern: string;
|
|
56
|
+
placeholder: string;
|
|
57
|
+
}
|
|
58
|
+
export interface NumberDataTypeParams {
|
|
59
|
+
error?: DataTypeError;
|
|
60
|
+
max?: number;
|
|
61
|
+
min?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface DateDataTypeParams {
|
|
64
|
+
error?: DataTypeError;
|
|
65
|
+
max?: string;
|
|
66
|
+
min?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface FileDataTypeParams {
|
|
69
|
+
accept?: string[];
|
|
70
|
+
fileSize?: number;
|
|
71
|
+
showAs: "IMAGE" | "VIDEO" | "FILE";
|
|
72
|
+
}
|
|
73
|
+
export type DataTypeParams = {
|
|
74
|
+
type: DataTypeEnum.String;
|
|
75
|
+
params?: StringDataTypeParams;
|
|
76
|
+
} | {
|
|
77
|
+
type: DataTypeEnum.Number;
|
|
78
|
+
params?: NumberDataTypeParams;
|
|
79
|
+
} | {
|
|
80
|
+
type: DataTypeEnum.Date;
|
|
81
|
+
params?: DateDataTypeParams;
|
|
82
|
+
} | {
|
|
83
|
+
type: DataTypeEnum.File;
|
|
84
|
+
params?: FileDataTypeParams;
|
|
85
|
+
} | {
|
|
86
|
+
type: DataTypeEnum.Object;
|
|
87
|
+
params?: undefined;
|
|
88
|
+
};
|
|
89
|
+
export interface Config {
|
|
90
|
+
format: ConfigEntities<FormatCapabilities>;
|
|
91
|
+
exchange: ConfigEntities;
|
|
92
|
+
transport: ConfigEntities;
|
|
93
|
+
revocation: ConfigEntities;
|
|
94
|
+
did: ConfigEntities<DidCapabilities>;
|
|
95
|
+
datatype: ConfigEntities<undefined, DataTypeParams>;
|
|
96
|
+
keyAlgorithm: ConfigEntities;
|
|
97
|
+
keyStorage: ConfigEntities<KeyStorageCapabilities>;
|
|
98
|
+
cacheEntities: ConfigEntities;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var KeyStorageSecurityEnum;
|
|
2
|
+
(function (KeyStorageSecurityEnum) {
|
|
3
|
+
KeyStorageSecurityEnum["HARDWARE"] = "HARDWARE";
|
|
4
|
+
KeyStorageSecurityEnum["SOFTWARE"] = "SOFTWARE";
|
|
5
|
+
})(KeyStorageSecurityEnum || (KeyStorageSecurityEnum = {}));
|
|
6
|
+
export var FormatFeatureEnum;
|
|
7
|
+
(function (FormatFeatureEnum) {
|
|
8
|
+
FormatFeatureEnum["SelectiveDisclosure"] = "SELECTIVE_DISCLOSURE";
|
|
9
|
+
FormatFeatureEnum["SupportsCredentialDesign"] = "SUPPORTS_CREDENTIAL_DESIGN";
|
|
10
|
+
FormatFeatureEnum["RequiresSchemaId"] = "REQUIRES_SCHEMA_ID";
|
|
11
|
+
})(FormatFeatureEnum || (FormatFeatureEnum = {}));
|
|
12
|
+
export var FormatSelectiveDisclosureEnum;
|
|
13
|
+
(function (FormatSelectiveDisclosureEnum) {
|
|
14
|
+
FormatSelectiveDisclosureEnum["AnyLevel"] = "ANY_LEVEL";
|
|
15
|
+
FormatSelectiveDisclosureEnum["SecondLevel"] = "SECOND_LEVEL";
|
|
16
|
+
})(FormatSelectiveDisclosureEnum || (FormatSelectiveDisclosureEnum = {}));
|
|
17
|
+
export var DataTypeEnum;
|
|
18
|
+
(function (DataTypeEnum) {
|
|
19
|
+
DataTypeEnum["String"] = "STRING";
|
|
20
|
+
DataTypeEnum["Number"] = "NUMBER";
|
|
21
|
+
DataTypeEnum["Date"] = "DATE";
|
|
22
|
+
DataTypeEnum["File"] = "FILE";
|
|
23
|
+
DataTypeEnum["Boolean"] = "BOOLEAN";
|
|
24
|
+
DataTypeEnum["Object"] = "OBJECT";
|
|
25
|
+
})(DataTypeEnum || (DataTypeEnum = {}));
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { BackupCreate, ImportBackupMetadata, UnexportableEntities } from "./backup";
|
|
2
|
+
import { Config } from "./config";
|
|
3
|
+
import { CredentialDetail, CredentialListItem, CredentialListQuery, CredentialRevocationCheckResponse, InvitationResultCredentialIssuance } from "./credential";
|
|
4
|
+
import { CredentialSchema, CredentialSchemaDetail, CredentialSchemaListQuery, ImportCredentialSchemaRequest, ShareCredentialSchemaResponse } from "./credentialSchema";
|
|
5
|
+
import { DidListItem, DidListQuery, DidRequest } from "./did";
|
|
6
|
+
import { HistoryListItem, HistoryListQuery } from "./history";
|
|
7
|
+
import { KeyRequest } from "./key";
|
|
8
|
+
import { ItemList } from "./list";
|
|
9
|
+
import { CreateProofRequest, InvitationResultProofRequest, PresentationDefinition, PresentationDefinitionRequestedCredential, PresentationSubmitCredentialRequest, ProofDetail, ProofListItem, ProofListQuery, ProposeProofResponse, ShareProofResponse } from "./proof";
|
|
10
|
+
import { CreateProofSchemaRequest, ImportProofSchemaRequest, ProofSchema, ProofSchemaListItem, ProofSchemaListQuery, ShareProofSchemaResponse } from "./proofSchema";
|
|
11
|
+
import { CreateTrustAnchorRequest, TrustAnchor, TrustAnchorListItem, TrustAnchorListQuery } from "./trust";
|
|
12
|
+
export * from "./backup";
|
|
13
|
+
export * from "./config";
|
|
14
|
+
export * from "./credential";
|
|
15
|
+
export * from "./credentialSchema";
|
|
16
|
+
export * from "./did";
|
|
17
|
+
export * from "./history";
|
|
18
|
+
export * from "./key";
|
|
19
|
+
export * from "./list";
|
|
20
|
+
export * from "./proof";
|
|
21
|
+
export * from "./proofSchema";
|
|
22
|
+
export * from "./trust";
|
|
23
|
+
export interface Version {
|
|
24
|
+
target: string;
|
|
25
|
+
buildTime: string;
|
|
26
|
+
branch: string;
|
|
27
|
+
tag: string;
|
|
28
|
+
commit: string;
|
|
29
|
+
rustVersion: string;
|
|
30
|
+
pipelineId: string;
|
|
31
|
+
}
|
|
32
|
+
export type InvitationResult = InvitationResultCredentialIssuance | InvitationResultProofRequest;
|
|
33
|
+
export interface ResolveJsonLdContextResponse {
|
|
34
|
+
context: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ONECore {
|
|
37
|
+
getVersion(): Promise<Version>;
|
|
38
|
+
getConfig(): Promise<Config>;
|
|
39
|
+
createOrganisation(uuid: string | undefined): Promise<string>;
|
|
40
|
+
generateKey(keyRequest: KeyRequest): Promise<string>;
|
|
41
|
+
createDid(didRequest: DidRequest): Promise<string>;
|
|
42
|
+
getDids(query: DidListQuery): Promise<ItemList<DidListItem>>;
|
|
43
|
+
handleInvitation(url: string, organisationId: string, transport: string[] | undefined): Promise<InvitationResult>;
|
|
44
|
+
holderAcceptCredential(interactionId: InvitationResultCredentialIssuance["interactionId"], didId: string, keyId: string | undefined): Promise<void>;
|
|
45
|
+
holderRejectCredential(interactionId: InvitationResultCredentialIssuance["interactionId"]): Promise<void>;
|
|
46
|
+
getPresentationDefinition(proofId: ProofDetail["id"]): Promise<PresentationDefinition>;
|
|
47
|
+
holderRejectProof(interactionId: InvitationResultProofRequest["interactionId"]): Promise<void>;
|
|
48
|
+
holderSubmitProof(interactionId: InvitationResultProofRequest["interactionId"], credentials: Record<PresentationDefinitionRequestedCredential["id"], PresentationSubmitCredentialRequest>, didId: string, keyId: string | undefined): Promise<void>;
|
|
49
|
+
getCredentials(query: CredentialListQuery): Promise<ItemList<CredentialListItem>>;
|
|
50
|
+
runTask(task: string): Promise<string>;
|
|
51
|
+
deleteProofClaims(proofId: ProofDetail["id"]): Promise<void>;
|
|
52
|
+
getCredential(credentialId: CredentialListItem["id"]): Promise<CredentialDetail>;
|
|
53
|
+
deleteCredential(credentialId: CredentialListItem["id"]): Promise<void>;
|
|
54
|
+
importCredentialSchema(request: ImportCredentialSchemaRequest): Promise<CredentialSchema["id"]>;
|
|
55
|
+
getCredentialSchema(credentialSchemaId: CredentialSchema["id"]): Promise<CredentialSchemaDetail>;
|
|
56
|
+
getCredentialSchemas(query: CredentialSchemaListQuery): Promise<ItemList<CredentialSchema>>;
|
|
57
|
+
deleteCredentialSchema(credentialSchemaId: CredentialSchema["id"]): Promise<void>;
|
|
58
|
+
createProof(request: CreateProofRequest): Promise<ProofDetail["id"]>;
|
|
59
|
+
shareProof(proofId: ProofDetail["id"]): Promise<ShareProofResponse>;
|
|
60
|
+
shareProofSchema(proofSchemaId: ProofSchema["id"]): Promise<ShareProofSchemaResponse>;
|
|
61
|
+
shareCredentialSchema(credentialSchemaId: CredentialSchema["id"]): Promise<ShareCredentialSchemaResponse>;
|
|
62
|
+
getProof(proofId: ProofDetail["id"]): Promise<ProofDetail>;
|
|
63
|
+
getProofs(query: ProofListQuery): Promise<ItemList<ProofListItem>>;
|
|
64
|
+
retractProof(proofId: ProofDetail["id"]): Promise<ProofDetail["id"]>;
|
|
65
|
+
proposeProof(exchange: string, organisationId: string): Promise<ProposeProofResponse>;
|
|
66
|
+
createProofSchema(request: CreateProofSchemaRequest): Promise<ProofSchema["id"]>;
|
|
67
|
+
getProofSchemas(query: ProofSchemaListQuery): Promise<ItemList<ProofSchemaListItem>>;
|
|
68
|
+
getProofSchema(proofSchemaId: ProofSchema["id"]): Promise<ProofSchema>;
|
|
69
|
+
deleteProofSchema(proofSchemaId: ProofSchema["id"]): Promise<void>;
|
|
70
|
+
importProofSchema(request: ImportProofSchemaRequest): Promise<ProofSchema["id"]>;
|
|
71
|
+
checkRevocation(credentialIds: Array<CredentialListItem["id"]>): Promise<CredentialRevocationCheckResponse[]>;
|
|
72
|
+
createTrustAnchor(request: CreateTrustAnchorRequest): Promise<TrustAnchor["id"]>;
|
|
73
|
+
getTrustAnchor(trustAnchorId: TrustAnchor["id"]): Promise<TrustAnchor>;
|
|
74
|
+
getTrustAnchors(query: TrustAnchorListQuery): Promise<ItemList<TrustAnchorListItem>>;
|
|
75
|
+
getHistory(query: HistoryListQuery): Promise<ItemList<HistoryListItem>>;
|
|
76
|
+
getHistoryEntry(historyId: HistoryListItem["id"]): Promise<HistoryListItem>;
|
|
77
|
+
createBackup(password: string, outputPath: string): Promise<BackupCreate>;
|
|
78
|
+
backupInfo(): Promise<UnexportableEntities>;
|
|
79
|
+
/**
|
|
80
|
+
* Start import procedure
|
|
81
|
+
*
|
|
82
|
+
* This call will open the provided backup file, other subsequent function calls like {@link getCredentials} will return data from the imported package
|
|
83
|
+
* After this successful call, either {@link finalizeImport} (to persist the changes) or {@link rollbackImport} (to revert to old data) must be called
|
|
84
|
+
* @param {string} password User password matching selected during creation of the backup file
|
|
85
|
+
* @param {string} inputPath Path to the stored backup file
|
|
86
|
+
*/
|
|
87
|
+
unpackBackup(password: string, inputPath: string): Promise<ImportBackupMetadata>;
|
|
88
|
+
/**
|
|
89
|
+
* Persist unpacked backup
|
|
90
|
+
*
|
|
91
|
+
* This call will delete/overwrite the previously stored entries
|
|
92
|
+
*/
|
|
93
|
+
finalizeImport(): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Close unpacked backup
|
|
96
|
+
*
|
|
97
|
+
* This call will restore the old entries prior calling {@link unpackBackup}
|
|
98
|
+
*/
|
|
99
|
+
rollbackImport(): Promise<void>;
|
|
100
|
+
resolveJsonldContext(url: string): Promise<ResolveJsonLdContextResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* Uninitialize the core instance
|
|
103
|
+
*
|
|
104
|
+
* Any following calls on this instance will fail.
|
|
105
|
+
* A new core instance has to be initialized after.
|
|
106
|
+
* @param {boolean} deleteData If true, also delete all data from the DB, otherwise data will be persisted for the next core instance
|
|
107
|
+
*/
|
|
108
|
+
uninitialize(deleteData: boolean): Promise<void>;
|
|
109
|
+
}
|
package/dist/src/core.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./backup";
|
|
2
|
+
export * from "./config";
|
|
3
|
+
export * from "./credential";
|
|
4
|
+
export * from "./credentialSchema";
|
|
5
|
+
export * from "./did";
|
|
6
|
+
export * from "./history";
|
|
7
|
+
export * from "./key";
|
|
8
|
+
export * from "./list";
|
|
9
|
+
export * from "./proof";
|
|
10
|
+
export * from "./proofSchema";
|
|
11
|
+
export * from "./trust";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { DataTypeEnum } from "./config";
|
|
2
|
+
import { CredentialSchema } from "./credentialSchema";
|
|
3
|
+
import { ListQuery, SortDirection } from "./list";
|
|
4
|
+
export declare enum CredentialStateEnum {
|
|
5
|
+
CREATED = "CREATED",
|
|
6
|
+
PENDING = "PENDING",
|
|
7
|
+
OFFERED = "OFFERED",
|
|
8
|
+
ACCEPTED = "ACCEPTED",
|
|
9
|
+
REJECTED = "REJECTED",
|
|
10
|
+
REVOKED = "REVOKED",
|
|
11
|
+
SUSPENDED = "SUSPENDED",
|
|
12
|
+
ERROR = "ERROR"
|
|
13
|
+
}
|
|
14
|
+
export type ClaimValue = {
|
|
15
|
+
dataType: DataTypeEnum.String | DataTypeEnum.Date | DataTypeEnum.File;
|
|
16
|
+
value: string;
|
|
17
|
+
array: false;
|
|
18
|
+
} | {
|
|
19
|
+
dataType: DataTypeEnum.Number;
|
|
20
|
+
value: number;
|
|
21
|
+
array: false;
|
|
22
|
+
} | {
|
|
23
|
+
dataType: DataTypeEnum.Boolean;
|
|
24
|
+
value: boolean;
|
|
25
|
+
array: false;
|
|
26
|
+
} | {
|
|
27
|
+
dataType: DataTypeEnum.Object;
|
|
28
|
+
value: Claim[];
|
|
29
|
+
array: false;
|
|
30
|
+
} | {
|
|
31
|
+
dataType: string;
|
|
32
|
+
value: string | number | boolean;
|
|
33
|
+
array: false;
|
|
34
|
+
} | {
|
|
35
|
+
dataType: string;
|
|
36
|
+
value: Claim[];
|
|
37
|
+
array: true;
|
|
38
|
+
};
|
|
39
|
+
export type Claim = ClaimValue & {
|
|
40
|
+
id: string;
|
|
41
|
+
key: string;
|
|
42
|
+
};
|
|
43
|
+
export interface CredentialListItem {
|
|
44
|
+
id: string;
|
|
45
|
+
createdDate: string;
|
|
46
|
+
issuanceDate: string;
|
|
47
|
+
lastModified: string;
|
|
48
|
+
revocationDate?: string;
|
|
49
|
+
issuerDid?: string;
|
|
50
|
+
state: CredentialStateEnum;
|
|
51
|
+
schema: CredentialSchema;
|
|
52
|
+
role: CredentialRoleEnum;
|
|
53
|
+
suspendEndDate?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface CredentialDetail extends CredentialListItem {
|
|
56
|
+
claims: Claim[];
|
|
57
|
+
redirectUri?: string;
|
|
58
|
+
lvvcIssuanceDate?: string;
|
|
59
|
+
mdocMsoValidity?: MdocMsoValidity;
|
|
60
|
+
}
|
|
61
|
+
export interface MdocMsoValidity {
|
|
62
|
+
expiration: string;
|
|
63
|
+
nextUpdate: string;
|
|
64
|
+
lastUpdate: string;
|
|
65
|
+
}
|
|
66
|
+
export declare enum CredentialRoleEnum {
|
|
67
|
+
HOLDER = "HOLDER",
|
|
68
|
+
ISSUER = "ISSUER",
|
|
69
|
+
VERIFIER = "VERIFIER"
|
|
70
|
+
}
|
|
71
|
+
export declare enum CredentialListQueryExactColumnEnum {
|
|
72
|
+
NAME = "NAME"
|
|
73
|
+
}
|
|
74
|
+
export declare enum SortableCredentialColumnEnum {
|
|
75
|
+
CREATED_DATE = "CREATED_DATE",
|
|
76
|
+
SCHEMA_NAME = "SCHEMA_NAME",
|
|
77
|
+
ISSUER_DID = "ISSUER_DID",
|
|
78
|
+
STATE = "STATE"
|
|
79
|
+
}
|
|
80
|
+
export declare enum CredentialListIncludeEntityType {
|
|
81
|
+
LAYOUT_PROPERTIES = "LAYOUT_PROPERTIES",
|
|
82
|
+
CREDENTIAL = "CREDENTIAL"
|
|
83
|
+
}
|
|
84
|
+
export declare enum CredentialListSearchType {
|
|
85
|
+
CLAIM_NAME = "CLAIM_NAME",
|
|
86
|
+
CLAIM_VALUE = "CLAIM_VALUE",
|
|
87
|
+
CREDENTIAL_SCHEMA_NAME = "CREDENTIAL_SCHEMA_NAME"
|
|
88
|
+
}
|
|
89
|
+
export type CredentialListQuery = ListQuery & {
|
|
90
|
+
sort?: SortableCredentialColumnEnum;
|
|
91
|
+
sortDirection?: SortDirection;
|
|
92
|
+
exact?: CredentialListQueryExactColumnEnum[];
|
|
93
|
+
role?: CredentialRoleEnum;
|
|
94
|
+
ids?: Array<CredentialListItem["id"]>;
|
|
95
|
+
status?: CredentialStateEnum[];
|
|
96
|
+
include?: CredentialListIncludeEntityType[];
|
|
97
|
+
} & ({
|
|
98
|
+
name?: string;
|
|
99
|
+
searchType?: never;
|
|
100
|
+
searchText?: never;
|
|
101
|
+
} | {
|
|
102
|
+
searchText?: string;
|
|
103
|
+
searchType?: CredentialListSearchType[];
|
|
104
|
+
name?: never;
|
|
105
|
+
});
|
|
106
|
+
export interface CredentialRevocationCheckResponse {
|
|
107
|
+
credentialId: string;
|
|
108
|
+
status: CredentialStateEnum;
|
|
109
|
+
success: boolean;
|
|
110
|
+
reason?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface InvitationResultCredentialIssuance {
|
|
113
|
+
interactionId: string;
|
|
114
|
+
credentialIds: Array<CredentialListItem["id"]>;
|
|
115
|
+
}
|