@bifold/core 2.4.4 → 2.4.5
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/lib/commonjs/index.js +29 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/ledger.js +145 -0
- package/lib/commonjs/utils/ledger.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ledger.js +137 -0
- package/lib/module/utils/ledger.js.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/ledger.d.ts +101 -0
- package/lib/typescript/src/utils/ledger.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +2 -0
- package/src/utils/ledger.ts +212 -0
package/lib/commonjs/index.js
CHANGED
|
@@ -126,6 +126,10 @@ var _exportNames = {
|
|
|
126
126
|
isValidAnonCredsCredential: true,
|
|
127
127
|
getCredentialIdentifiers: true,
|
|
128
128
|
buildFieldsFromAnonCredsCredential: true,
|
|
129
|
+
IndyLedger: true,
|
|
130
|
+
getIndyLedgers: true,
|
|
131
|
+
readIndyLedgersFromFile: true,
|
|
132
|
+
writeIndyLedgersToFile: true,
|
|
129
133
|
CredentialMetadata: true,
|
|
130
134
|
BasicMessageMetadata: true,
|
|
131
135
|
BaseTourID: true
|
|
@@ -334,6 +338,12 @@ Object.defineProperty(exports, "ImageAssets", {
|
|
|
334
338
|
return _theme.Assets;
|
|
335
339
|
}
|
|
336
340
|
});
|
|
341
|
+
Object.defineProperty(exports, "IndyLedger", {
|
|
342
|
+
enumerable: true,
|
|
343
|
+
get: function () {
|
|
344
|
+
return _ledger.IndyLedger;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
337
347
|
Object.defineProperty(exports, "InfoBox", {
|
|
338
348
|
enumerable: true,
|
|
339
349
|
get: function () {
|
|
@@ -678,6 +688,12 @@ Object.defineProperty(exports, "getCredentialIdentifiers", {
|
|
|
678
688
|
return _credential.getCredentialIdentifiers;
|
|
679
689
|
}
|
|
680
690
|
});
|
|
691
|
+
Object.defineProperty(exports, "getIndyLedgers", {
|
|
692
|
+
enumerable: true,
|
|
693
|
+
get: function () {
|
|
694
|
+
return _ledger.getIndyLedgers;
|
|
695
|
+
}
|
|
696
|
+
});
|
|
681
697
|
Object.defineProperty(exports, "homeTourSteps", {
|
|
682
698
|
enumerable: true,
|
|
683
699
|
get: function () {
|
|
@@ -732,6 +748,12 @@ Object.defineProperty(exports, "proofRequestTourSteps", {
|
|
|
732
748
|
return _ProofRequestTourSteps.proofRequestTourSteps;
|
|
733
749
|
}
|
|
734
750
|
});
|
|
751
|
+
Object.defineProperty(exports, "readIndyLedgersFromFile", {
|
|
752
|
+
enumerable: true,
|
|
753
|
+
get: function () {
|
|
754
|
+
return _ledger.readIndyLedgersFromFile;
|
|
755
|
+
}
|
|
756
|
+
});
|
|
735
757
|
Object.defineProperty(exports, "reducer", {
|
|
736
758
|
enumerable: true,
|
|
737
759
|
get: function () {
|
|
@@ -865,6 +887,12 @@ Object.defineProperty(exports, "walletTimeout", {
|
|
|
865
887
|
return _constants.walletTimeout;
|
|
866
888
|
}
|
|
867
889
|
});
|
|
890
|
+
Object.defineProperty(exports, "writeIndyLedgersToFile", {
|
|
891
|
+
enumerable: true,
|
|
892
|
+
get: function () {
|
|
893
|
+
return _ledger.writeIndyLedgersToFile;
|
|
894
|
+
}
|
|
895
|
+
});
|
|
868
896
|
var _core = require("@credo-ts/core");
|
|
869
897
|
var _reactHooks = _interopRequireDefault(require("@credo-ts/react-hooks"));
|
|
870
898
|
var _App = _interopRequireDefault(require("./App"));
|
|
@@ -996,6 +1024,7 @@ var _agent = require("./utils/agent");
|
|
|
996
1024
|
var _helpers = require("./utils/helpers");
|
|
997
1025
|
var _credential = require("./utils/credential");
|
|
998
1026
|
var _oca = require("./utils/oca");
|
|
1027
|
+
var _ledger = require("./utils/ledger");
|
|
999
1028
|
var _metadata = require("./types/metadata");
|
|
1000
1029
|
var _containerApi = require("./container-api");
|
|
1001
1030
|
Object.keys(_containerApi).forEach(function (key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_core","require","_reactHooks","_interopRequireDefault","_App","components","_interopRequireWildcard","exports","_Button","_IconButton","_BulletPoint","_CheckBoxRow","_ContentGradient","_CredentialCard","_ErrorBoundary","_InfoBox","_ErrorModal","_SafeAreaModal","_Record","_InfoTextBox","_Link","_Text","_ThemedText","_BaseToast","_ToastConfig","_AttachTourStep","_CredentialOfferTourSteps","_CredentialsTourSteps","_HomeTourSteps","_ProofRequestTourSteps","_TourBox","_LimitedTextInput","_HomeFooterView","_KeyboardView","_NotificationListItem","contexts","_activity","_auth","_navigation","_network","_tourContext","_tourProvider","_AttemptLockout","_Developer","_DeveloperModal","_developerMode","_FauxHeader","_OnboardingPages","_Preface","_Splash","_Terms","_UpdateAvailable","_Biometry","_keychain","_logger","types","_Scan","_Onboarding","_defaultStackOptions","_constants","_OpenIDCredentialRecordProvider","_containerImpl","_useBifoldAgentSetup","_screenCapture","_defaultLayoutOptions","_themeBuilder","_bifoldLogger","_navigators","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_storage","_attestation","_versionCheck","_localization","_store","_store2","_deepLinks","_theme","_theme2","_animatedComponents","_animatedComponents2","_testable","_navigators2","_luminance","_error","_migration","_agent","_helpers","_credential","_oca","_metadata","_containerApi","_tour","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_core","require","_reactHooks","_interopRequireDefault","_App","components","_interopRequireWildcard","exports","_Button","_IconButton","_BulletPoint","_CheckBoxRow","_ContentGradient","_CredentialCard","_ErrorBoundary","_InfoBox","_ErrorModal","_SafeAreaModal","_Record","_InfoTextBox","_Link","_Text","_ThemedText","_BaseToast","_ToastConfig","_AttachTourStep","_CredentialOfferTourSteps","_CredentialsTourSteps","_HomeTourSteps","_ProofRequestTourSteps","_TourBox","_LimitedTextInput","_HomeFooterView","_KeyboardView","_NotificationListItem","contexts","_activity","_auth","_navigation","_network","_tourContext","_tourProvider","_AttemptLockout","_Developer","_DeveloperModal","_developerMode","_FauxHeader","_OnboardingPages","_Preface","_Splash","_Terms","_UpdateAvailable","_Biometry","_keychain","_logger","types","_Scan","_Onboarding","_defaultStackOptions","_constants","_OpenIDCredentialRecordProvider","_containerImpl","_useBifoldAgentSetup","_screenCapture","_defaultLayoutOptions","_themeBuilder","_bifoldLogger","_navigators","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_storage","_attestation","_versionCheck","_localization","_store","_store2","_deepLinks","_theme","_theme2","_animatedComponents","_animatedComponents2","_testable","_navigators2","_luminance","_error","_migration","_agent","_helpers","_credential","_oca","_ledger","_metadata","_containerApi","_tour","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","set","getOwnPropertyDescriptor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IndyLedger = void 0;
|
|
7
|
+
exports._fetchUrlContent = _fetchUrlContent;
|
|
8
|
+
exports.getIndyLedgers = getIndyLedgers;
|
|
9
|
+
exports.readIndyLedgersFromFile = readIndyLedgersFromFile;
|
|
10
|
+
exports.writeIndyLedgersToFile = writeIndyLedgersToFile;
|
|
11
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const INDY_NETWORK_URL = 'https://raw.githubusercontent.com/hyperledger/indy-node-monitor/main/fetch-validator-status/networks.json';
|
|
14
|
+
const ERROR_TAG = 'LEDGER ERROR';
|
|
15
|
+
let IndyLedger = exports.IndyLedger = /*#__PURE__*/function (IndyLedger) {
|
|
16
|
+
IndyLedger["SOVRIN_BUILDER_NET"] = "sbn";
|
|
17
|
+
IndyLedger["SOVRIN_STAGING_NET"] = "ssn";
|
|
18
|
+
IndyLedger["SOVERIN_MAIN_NET"] = "smn";
|
|
19
|
+
IndyLedger["LOCAL_VON_NETWORK"] = "vn";
|
|
20
|
+
IndyLedger["LINUX_LOCAL_VON_NETWORK"] = "lln";
|
|
21
|
+
IndyLedger["BCOVRIN_DEV"] = "bcd";
|
|
22
|
+
IndyLedger["BCOVRIN_TEST"] = "bct";
|
|
23
|
+
IndyLedger["BCOVRIN"] = "bcp";
|
|
24
|
+
IndyLedger["GREENLIGHT_DEV_LEDGER"] = "gld";
|
|
25
|
+
IndyLedger["INDICO_MAINNET"] = "imn";
|
|
26
|
+
IndyLedger["INDICO_DEMONET"] = "idn";
|
|
27
|
+
IndyLedger["INDICO_TESTNET"] = "itn";
|
|
28
|
+
IndyLedger["CANDY_DEV_NETWORK"] = "cdn";
|
|
29
|
+
IndyLedger["CANDY_TEST_NETWORK"] = "ctn";
|
|
30
|
+
IndyLedger["CANDY_PRODUCTION_NETWORK"] = "cpn";
|
|
31
|
+
return IndyLedger;
|
|
32
|
+
}({}); // This interface allows us to abstract the file system operations,
|
|
33
|
+
// preventing android from complaining about the use of the Node.js module 'fs'.
|
|
34
|
+
/**
|
|
35
|
+
* Fetches the content from a given URL and returns it as a Promise.
|
|
36
|
+
*
|
|
37
|
+
* @throws {Error} - Throws an error if the fetch operation fails.
|
|
38
|
+
* @template T - The type of content expected from the URL.
|
|
39
|
+
* @param {string} url - The URL to fetch content from.
|
|
40
|
+
* @returns {*} {Promise<T>} - A promise that resolves to the content fetched from the URL
|
|
41
|
+
*/
|
|
42
|
+
async function _fetchUrlContent(url) {
|
|
43
|
+
try {
|
|
44
|
+
const response = await _axios.default.get(url);
|
|
45
|
+
return response.data;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
throw new Error(`${ERROR_TAG}: Failed to fetch content from URL ${url}: ${error.message}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Fetches and returns a list of Indy ledgers based on the provided configurations.
|
|
53
|
+
*
|
|
54
|
+
* @throws {Error} - Throws an error if a ledgerConfig is not found in the IndyLedgersRecord.
|
|
55
|
+
* @param {IndyLedgerConfig[]} indyLedgerConfigs - The list of supported Indy ledger configurations.
|
|
56
|
+
* @returns {*} {Promise<IndyLedgerJSON[]>} - A promise that resolves to an array of ledgers.
|
|
57
|
+
*/
|
|
58
|
+
async function getIndyLedgers(indyLedgerConfigs) {
|
|
59
|
+
if (!indyLedgerConfigs.length) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
const allIndyLedgers = await _fetchUrlContent(INDY_NETWORK_URL);
|
|
63
|
+
const ledgers = [];
|
|
64
|
+
// Iterate through the supported network configs and map them to the Indy ledgers
|
|
65
|
+
for (const ledgerConfig of indyLedgerConfigs) {
|
|
66
|
+
const indyLedger = allIndyLedgers[ledgerConfig.ledgerId];
|
|
67
|
+
if (!indyLedger) {
|
|
68
|
+
throw new Error(`${ERROR_TAG}: Ledger config for ${ledgerConfig.ledgerId} not found`);
|
|
69
|
+
}
|
|
70
|
+
const ledgerId = indyLedger.name.split(' ').filter(word => !/\W+/im.test(word)).join('');
|
|
71
|
+
ledgers.push({
|
|
72
|
+
id: ledgerId,
|
|
73
|
+
indyNamespace: indyLedger.indyNamespace,
|
|
74
|
+
isProduction: ledgerConfig.isProduction,
|
|
75
|
+
connectOnStartup: !ledgerConfig.doNotConnectOnStartup,
|
|
76
|
+
// This url will need to be fetched to get the genesis transactions
|
|
77
|
+
genesisTransactions: indyLedger.genesisUrl
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Step 1: Collect all genesis transaction promises
|
|
82
|
+
const genesisPromises = ledgers.map(ledger => _fetchUrlContent(ledger.genesisTransactions));
|
|
83
|
+
|
|
84
|
+
// Step 2: Await all promises to resolve in parallel
|
|
85
|
+
const genesisTransactions = await Promise.all(genesisPromises);
|
|
86
|
+
|
|
87
|
+
// Step 3: Assign the fetched genesis transactions back to the ledgers
|
|
88
|
+
genesisTransactions.forEach((transactions, index) => {
|
|
89
|
+
ledgers[index].genesisTransactions = transactions.trim();
|
|
90
|
+
});
|
|
91
|
+
return ledgers;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Writes the provided Indy ledgers to a JSON file at the specified file path.
|
|
96
|
+
*
|
|
97
|
+
* @throws {Error} - Throws an error if writing to the file fails or if the file path is invalid.
|
|
98
|
+
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for writing the file.
|
|
99
|
+
* @param {string} filePath - The path to the JSON file where the ledgers should be written.
|
|
100
|
+
* @param {IndyLedgerJSON[]} ledgers - The array of Indy ledgers to write to the file.
|
|
101
|
+
* @returns {*} {void}
|
|
102
|
+
*/
|
|
103
|
+
function writeIndyLedgersToFile(fileSystem, filePath, ledgers) {
|
|
104
|
+
try {
|
|
105
|
+
if (!filePath.endsWith('.json')) {
|
|
106
|
+
throw new Error('File path must point to a JSON file');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Skip writing to file if the new ledgers are the same
|
|
110
|
+
if (fileSystem.fileExists(filePath) && JSON.stringify(readIndyLedgersFromFile(fileSystem, filePath)) === JSON.stringify(ledgers)) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const jsonContent = JSON.stringify(ledgers, null, 2);
|
|
114
|
+
|
|
115
|
+
// Convert to absolute path ie: ./ledgers.json -> /Users/username/project/ledgers.json
|
|
116
|
+
const absoluteFilePath = fileSystem.pathResolve(filePath);
|
|
117
|
+
fileSystem.writeFile(absoluteFilePath, jsonContent);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
throw new Error(`${ERROR_TAG}: Failed to write ledgers to file ${filePath}: ${error.message}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Reads and parses Indy ledgers from a JSON file at the specified file path.
|
|
125
|
+
*
|
|
126
|
+
* @throws {Error} - Throws an error if reading from the file fails, if the file path is invalid, or if parsing fails.
|
|
127
|
+
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for reading the file.
|
|
128
|
+
* @param {string} filePath - The path to the JSON file to read the ledgers from.
|
|
129
|
+
* @returns {*} {IndyLedgerJSON[]} - An array of Indy ledgers read from the file.
|
|
130
|
+
*/
|
|
131
|
+
function readIndyLedgersFromFile(fileSystem, filePath) {
|
|
132
|
+
try {
|
|
133
|
+
if (!filePath.endsWith('.json')) {
|
|
134
|
+
throw new Error('File path must point to a JSON file');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Convert to absolute path ie: ./ledgers.json -> /Users/username/project/ledgers.json
|
|
138
|
+
const absoluteFilePath = fileSystem.pathResolve(filePath);
|
|
139
|
+
const jsonContent = fileSystem.readFile(absoluteFilePath);
|
|
140
|
+
return JSON.parse(jsonContent);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
throw new Error(`${ERROR_TAG}: Failed to read ledgers from file ${filePath}: ${error.message}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_axios","_interopRequireDefault","require","e","__esModule","default","INDY_NETWORK_URL","ERROR_TAG","IndyLedger","exports","_fetchUrlContent","url","response","axios","get","data","error","Error","message","getIndyLedgers","indyLedgerConfigs","length","allIndyLedgers","ledgers","ledgerConfig","indyLedger","ledgerId","name","split","filter","word","test","join","push","id","indyNamespace","isProduction","connectOnStartup","doNotConnectOnStartup","genesisTransactions","genesisUrl","genesisPromises","map","ledger","Promise","all","forEach","transactions","index","trim","writeIndyLedgersToFile","fileSystem","filePath","endsWith","fileExists","JSON","stringify","readIndyLedgersFromFile","jsonContent","absoluteFilePath","pathResolve","writeFile","readFile","parse"],"sourceRoot":"../../../src","sources":["utils/ledger.ts"],"mappings":";;;;;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAyB,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEzB,MAAMG,gBAAgB,GACpB,2GAA2G;AAE7G,MAAMC,SAAS,GAAG,cAAc;AAAA,IAEpBC,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA,OAuCtB;AACA;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeE,gBAAgBA,CAAIC,GAAW,EAAc;EACjE,IAAI;I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,EAAEC,QAAgB,EAAoB;EAC5G,IAAI;IACF,IAAI,CAACA,QAAQ,CAACC,QAAQ,CAAC,OAAO,CAAC,EAAE;MAC/B,MAAM,IAAIpC,KAAK,CAAC,qCAAqC,CAAC;IACxD;;IAEA;IACA,MAAM0C,gBAAgB,GAAGR,UAAU,CAACS,WAAW,CAACR,QAAQ,CAAC;IACzD,MAAMM,WAAW,GAAGP,UAAU,CAACW,QAAQ,CAACH,gBAAgB,CAAC;IAEzD,OAAOJ,IAAI,CAACQ,KAAK,CAACL,WAAW,CAAC;EAChC,CAAC,CAAC,OAAO1C,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAC,GAAGV,SAAS,sCAAsC6C,QAAQ,KAAKpC,KAAK,CAACE,OAAO,EAAE,CAAC;EACjG;AACF","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -92,6 +92,7 @@ export { createLinkSecretIfRequired, getAgentModules } from './utils/agent';
|
|
|
92
92
|
export { removeExistingInvitationsById, connectFromScanOrDeepLink, formatTime, useCredentialConnectionLabel, getConnectionName } from './utils/helpers';
|
|
93
93
|
export { isValidAnonCredsCredential, getCredentialIdentifiers } from './utils/credential';
|
|
94
94
|
export { buildFieldsFromAnonCredsCredential } from './utils/oca';
|
|
95
|
+
export { IndyLedger, getIndyLedgers, readIndyLedgersFromFile, writeIndyLedgersToFile } from './utils/ledger';
|
|
95
96
|
export { CredentialMetadata, BasicMessageMetadata } from './types/metadata';
|
|
96
97
|
export { InlineErrorPosition } from './types/error';
|
|
97
98
|
export * from './container-api';
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Agent","AgentProvider","createApp","components","ButtonImpl","Button","ButtonType","IconButton","ButtonLocation","BulletPoint","CheckBoxRow","ContentGradient","CredentialCard","ErrorBoundaryWrapper","InfoBox","InfoBoxType","ErrorModal","SafeAreaModal","Record","InfoTextBox","Link","Text","ThemedText","ToastType","toastConfig","AttachTourStep","credentialOfferTourSteps","credentialsTourSteps","homeTourSteps","proofRequestTourSteps","TourBox","LimitedTextInput","HomeFooterView","KeyboardView","NotificationListItem","contexts","AutoLockTime","ActivityProvider","useActivity","AuthProvider","NavContainer","NetworkProvider","useTour","TourProvider","AttemptLockout","Developer","DeveloperModal","useDeveloperMode","FauxHeader","OnboardingPages","Preface","Splash","Terms","UpdateAvailable","Biometry","loadLoginAttempt","isBiometricsActive","BifoldLogger","types","Scan","Onboarding","DefaultScreenOptionsDictionary","useDefaultStackOptions","PINRules","walletTimeout","tours","attemptLockoutConfig","OpenIDCredentialRecordProvider","defaultConfig","defaultHistoryEventsLogger","useBifoldAgentSetup","usePreventScreenCapture","DefaultScreenLayoutOptions","ThemeBuilder","bifoldLoggerInstance","LocalStorageKeys","initLanguages","initStoredLanguage","translationResources","Locales","defaultState","mergeReducers","StoreProvider","StoreContext","useStore","default","Store","DispatchAction","reducer","useDeepLinks","Assets","ImageAssets","ThemeProvider","useTheme","AnimatedComponentsProvider","useAnimatedComponents","ColorPalette","animatedComponents","bifoldTheme","useAuth","useNetwork","testIdWithKey","testIdForAccessabilityLabel","Screens","Stacks","TabStacks","createStyles","statusBarStyleForColor","StatusBarStyles","BifoldError","EventTypes","migrateToAskar","createLinkSecretIfRequired","getAgentModules","removeExistingInvitationsById","connectFromScanOrDeepLink","formatTime","useCredentialConnectionLabel","getConnectionName","isValidAnonCredsCredential","getCredentialIdentifiers","buildFieldsFromAnonCredsCredential","CredentialMetadata","BasicMessageMetadata","InlineErrorPosition","MainContainer","BaseTourID","LockoutReason","HomeContentView"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;;AAGA,SAASA,KAAK,QAAQ,gBAAgB;AACtC,OAAOC,aAAa,MAAM,uBAAuB;AAEjD,OAAOC,SAAS,MAAM,OAAO;AAC7B,OAAO,KAAKC,UAAU,MAAM,cAAc;AAC1C,SAA4BC,UAAU,IAAIC,MAAM,EAAEC,UAAU,QAAQ,6BAA6B;AACjG,OAAOC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B;AACrG,SAASC,OAAO,IAAIC,KAAK,EAAEC,cAAc,EAAEC,OAAO,QAAQ,2BAA2B;AACrF,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,MAAM,IAAIC,WAAW,QAAQ,SAAS;AAC/C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,kBAAkB;AAC1D,SAASC,0BAA0B,EAAEC,qBAAqB,QAAQ,gCAAgC;AAClG,SAASC,YAAY,QAAQ,SAAS;AACtC,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASC,WAAW,QAAQ,SAAS;AACrC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,aAAa,EAAEC,2BAA2B,QAAQ,kBAAkB;AAC7E,SAASC,OAAO,EAAEC,MAAM,EAAEC,SAAS,QAAQ,oBAAoB;AAC/D,SAASC,YAAY,QAAQ,2BAA2B;AACxD,SAASC,sBAAsB,EAAEC,eAAe,QAAQ,mBAAmB;AAC3E,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,0BAA0B,EAAEC,eAAe,QAAQ,eAAe;AAC3E,SACEC,6BAA6B,EAC7BC,yBAAyB,EACzBC,UAAU,EACVC,4BAA4B,EAC5BC,iBAAiB,QACZ,iBAAiB;AACxB,SAASC,0BAA0B,EAAEC,wBAAwB,QAAQ,oBAAoB;AACzF,SAASC,kCAAkC,QAAQ,aAAa;
|
|
1
|
+
{"version":3,"names":["Agent","AgentProvider","createApp","components","ButtonImpl","Button","ButtonType","IconButton","ButtonLocation","BulletPoint","CheckBoxRow","ContentGradient","CredentialCard","ErrorBoundaryWrapper","InfoBox","InfoBoxType","ErrorModal","SafeAreaModal","Record","InfoTextBox","Link","Text","ThemedText","ToastType","toastConfig","AttachTourStep","credentialOfferTourSteps","credentialsTourSteps","homeTourSteps","proofRequestTourSteps","TourBox","LimitedTextInput","HomeFooterView","KeyboardView","NotificationListItem","contexts","AutoLockTime","ActivityProvider","useActivity","AuthProvider","NavContainer","NetworkProvider","useTour","TourProvider","AttemptLockout","Developer","DeveloperModal","useDeveloperMode","FauxHeader","OnboardingPages","Preface","Splash","Terms","UpdateAvailable","Biometry","loadLoginAttempt","isBiometricsActive","BifoldLogger","types","Scan","Onboarding","DefaultScreenOptionsDictionary","useDefaultStackOptions","PINRules","walletTimeout","tours","attemptLockoutConfig","OpenIDCredentialRecordProvider","defaultConfig","defaultHistoryEventsLogger","useBifoldAgentSetup","usePreventScreenCapture","DefaultScreenLayoutOptions","ThemeBuilder","bifoldLoggerInstance","LocalStorageKeys","initLanguages","initStoredLanguage","translationResources","Locales","defaultState","mergeReducers","StoreProvider","StoreContext","useStore","default","Store","DispatchAction","reducer","useDeepLinks","Assets","ImageAssets","ThemeProvider","useTheme","AnimatedComponentsProvider","useAnimatedComponents","ColorPalette","animatedComponents","bifoldTheme","useAuth","useNetwork","testIdWithKey","testIdForAccessabilityLabel","Screens","Stacks","TabStacks","createStyles","statusBarStyleForColor","StatusBarStyles","BifoldError","EventTypes","migrateToAskar","createLinkSecretIfRequired","getAgentModules","removeExistingInvitationsById","connectFromScanOrDeepLink","formatTime","useCredentialConnectionLabel","getConnectionName","isValidAnonCredsCredential","getCredentialIdentifiers","buildFieldsFromAnonCredsCredential","IndyLedger","getIndyLedgers","readIndyLedgersFromFile","writeIndyLedgersToFile","CredentialMetadata","BasicMessageMetadata","InlineErrorPosition","MainContainer","BaseTourID","LockoutReason","HomeContentView"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;;AAGA,SAASA,KAAK,QAAQ,gBAAgB;AACtC,OAAOC,aAAa,MAAM,uBAAuB;AAEjD,OAAOC,SAAS,MAAM,OAAO;AAC7B,OAAO,KAAKC,UAAU,MAAM,cAAc;AAC1C,SAA4BC,UAAU,IAAIC,MAAM,EAAEC,UAAU,QAAQ,6BAA6B;AACjG,OAAOC,UAAU,IA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AE/C,SACEjI,SAAS,EACTF,KAAK,EACLC,aAAa,EACbsC,YAAY,EACZE,eAAe,EACfE,YAAY,EACZD,OAAO,EACPjB,cAAc,EACdK,OAAO,EACPsC,aAAa,EACbC,0BAA0B,EAC1BzC,aAAa,EACbD,oBAAoB,EACpBD,wBAAwB,EACxBG,qBAAqB,EACrBvB,UAAU,EACVE,cAAc,EACdE,WAAW,EACXE,cAAc,EACdC,oBAAoB,EACpB6D,oBAAoB,EACpB/D,eAAe,EACfK,UAAU,EACVC,aAAa,EACbV,UAAU,EACV8B,gBAAgB,EAChBC,WAAW,EACXnB,WAAW,EACXL,OAAO,EACPC,WAAW,EACXK,IAAI,EACJgB,YAAY,EACZb,SAAS,EACTC,WAAW,EACXgB,YAAY,EACZS,eAAe,EACfkB,8BAA8B,EAC9BjC,oBAAoB,EACpB4B,sBAAsB,EACtBQ,mBAAmB,EACnBC,uBAAuB,EACvBpB,MAAM,EACNN,SAAS,EACTC,cAAc,EACdC,gBAAgB,EAChBC,UAAU,EACVI,KAAK,EACLF,OAAO,EACPG,eAAe,EACfrB,cAAc,IAAIoG,eAAe,EACjC9E,QAAQ,EACRV,cAAc,EACd1B,MAAM,EACNyC,IAAI,EACJC,UAAU,EACVF,KAAK,EACLvD,UAAU,EACVgC,QAAQ,EACRd,IAAI,EACJC,UAAU,EACViC,gBAAgB,EAChBC,kBAAkB,EAClBnD,MAAM,EACNoD,YAAY,EACZ1B,gBAAgB,EAChBE,YAAY,EACZxB,WAAW,EACXsD,QAAQ,EACRC,aAAa,EACbE,oBAAoB,EACpBD,KAAK,EACLJ,8BAA8B,EAC9BW,0BAA0B,EAC1BC,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
const INDY_NETWORK_URL = 'https://raw.githubusercontent.com/hyperledger/indy-node-monitor/main/fetch-validator-status/networks.json';
|
|
3
|
+
const ERROR_TAG = 'LEDGER ERROR';
|
|
4
|
+
export let IndyLedger = /*#__PURE__*/function (IndyLedger) {
|
|
5
|
+
IndyLedger["SOVRIN_BUILDER_NET"] = "sbn";
|
|
6
|
+
IndyLedger["SOVRIN_STAGING_NET"] = "ssn";
|
|
7
|
+
IndyLedger["SOVERIN_MAIN_NET"] = "smn";
|
|
8
|
+
IndyLedger["LOCAL_VON_NETWORK"] = "vn";
|
|
9
|
+
IndyLedger["LINUX_LOCAL_VON_NETWORK"] = "lln";
|
|
10
|
+
IndyLedger["BCOVRIN_DEV"] = "bcd";
|
|
11
|
+
IndyLedger["BCOVRIN_TEST"] = "bct";
|
|
12
|
+
IndyLedger["BCOVRIN"] = "bcp";
|
|
13
|
+
IndyLedger["GREENLIGHT_DEV_LEDGER"] = "gld";
|
|
14
|
+
IndyLedger["INDICO_MAINNET"] = "imn";
|
|
15
|
+
IndyLedger["INDICO_DEMONET"] = "idn";
|
|
16
|
+
IndyLedger["INDICO_TESTNET"] = "itn";
|
|
17
|
+
IndyLedger["CANDY_DEV_NETWORK"] = "cdn";
|
|
18
|
+
IndyLedger["CANDY_TEST_NETWORK"] = "ctn";
|
|
19
|
+
IndyLedger["CANDY_PRODUCTION_NETWORK"] = "cpn";
|
|
20
|
+
return IndyLedger;
|
|
21
|
+
}({});
|
|
22
|
+
|
|
23
|
+
// This interface allows us to abstract the file system operations,
|
|
24
|
+
// preventing android from complaining about the use of the Node.js module 'fs'.
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetches the content from a given URL and returns it as a Promise.
|
|
28
|
+
*
|
|
29
|
+
* @throws {Error} - Throws an error if the fetch operation fails.
|
|
30
|
+
* @template T - The type of content expected from the URL.
|
|
31
|
+
* @param {string} url - The URL to fetch content from.
|
|
32
|
+
* @returns {*} {Promise<T>} - A promise that resolves to the content fetched from the URL
|
|
33
|
+
*/
|
|
34
|
+
export async function _fetchUrlContent(url) {
|
|
35
|
+
try {
|
|
36
|
+
const response = await axios.get(url);
|
|
37
|
+
return response.data;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw new Error(`${ERROR_TAG}: Failed to fetch content from URL ${url}: ${error.message}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Fetches and returns a list of Indy ledgers based on the provided configurations.
|
|
45
|
+
*
|
|
46
|
+
* @throws {Error} - Throws an error if a ledgerConfig is not found in the IndyLedgersRecord.
|
|
47
|
+
* @param {IndyLedgerConfig[]} indyLedgerConfigs - The list of supported Indy ledger configurations.
|
|
48
|
+
* @returns {*} {Promise<IndyLedgerJSON[]>} - A promise that resolves to an array of ledgers.
|
|
49
|
+
*/
|
|
50
|
+
export async function getIndyLedgers(indyLedgerConfigs) {
|
|
51
|
+
if (!indyLedgerConfigs.length) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const allIndyLedgers = await _fetchUrlContent(INDY_NETWORK_URL);
|
|
55
|
+
const ledgers = [];
|
|
56
|
+
// Iterate through the supported network configs and map them to the Indy ledgers
|
|
57
|
+
for (const ledgerConfig of indyLedgerConfigs) {
|
|
58
|
+
const indyLedger = allIndyLedgers[ledgerConfig.ledgerId];
|
|
59
|
+
if (!indyLedger) {
|
|
60
|
+
throw new Error(`${ERROR_TAG}: Ledger config for ${ledgerConfig.ledgerId} not found`);
|
|
61
|
+
}
|
|
62
|
+
const ledgerId = indyLedger.name.split(' ').filter(word => !/\W+/im.test(word)).join('');
|
|
63
|
+
ledgers.push({
|
|
64
|
+
id: ledgerId,
|
|
65
|
+
indyNamespace: indyLedger.indyNamespace,
|
|
66
|
+
isProduction: ledgerConfig.isProduction,
|
|
67
|
+
connectOnStartup: !ledgerConfig.doNotConnectOnStartup,
|
|
68
|
+
// This url will need to be fetched to get the genesis transactions
|
|
69
|
+
genesisTransactions: indyLedger.genesisUrl
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Step 1: Collect all genesis transaction promises
|
|
74
|
+
const genesisPromises = ledgers.map(ledger => _fetchUrlContent(ledger.genesisTransactions));
|
|
75
|
+
|
|
76
|
+
// Step 2: Await all promises to resolve in parallel
|
|
77
|
+
const genesisTransactions = await Promise.all(genesisPromises);
|
|
78
|
+
|
|
79
|
+
// Step 3: Assign the fetched genesis transactions back to the ledgers
|
|
80
|
+
genesisTransactions.forEach((transactions, index) => {
|
|
81
|
+
ledgers[index].genesisTransactions = transactions.trim();
|
|
82
|
+
});
|
|
83
|
+
return ledgers;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Writes the provided Indy ledgers to a JSON file at the specified file path.
|
|
88
|
+
*
|
|
89
|
+
* @throws {Error} - Throws an error if writing to the file fails or if the file path is invalid.
|
|
90
|
+
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for writing the file.
|
|
91
|
+
* @param {string} filePath - The path to the JSON file where the ledgers should be written.
|
|
92
|
+
* @param {IndyLedgerJSON[]} ledgers - The array of Indy ledgers to write to the file.
|
|
93
|
+
* @returns {*} {void}
|
|
94
|
+
*/
|
|
95
|
+
export function writeIndyLedgersToFile(fileSystem, filePath, ledgers) {
|
|
96
|
+
try {
|
|
97
|
+
if (!filePath.endsWith('.json')) {
|
|
98
|
+
throw new Error('File path must point to a JSON file');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Skip writing to file if the new ledgers are the same
|
|
102
|
+
if (fileSystem.fileExists(filePath) && JSON.stringify(readIndyLedgersFromFile(fileSystem, filePath)) === JSON.stringify(ledgers)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const jsonContent = JSON.stringify(ledgers, null, 2);
|
|
106
|
+
|
|
107
|
+
// Convert to absolute path ie: ./ledgers.json -> /Users/username/project/ledgers.json
|
|
108
|
+
const absoluteFilePath = fileSystem.pathResolve(filePath);
|
|
109
|
+
fileSystem.writeFile(absoluteFilePath, jsonContent);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
throw new Error(`${ERROR_TAG}: Failed to write ledgers to file ${filePath}: ${error.message}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Reads and parses Indy ledgers from a JSON file at the specified file path.
|
|
117
|
+
*
|
|
118
|
+
* @throws {Error} - Throws an error if reading from the file fails, if the file path is invalid, or if parsing fails.
|
|
119
|
+
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for reading the file.
|
|
120
|
+
* @param {string} filePath - The path to the JSON file to read the ledgers from.
|
|
121
|
+
* @returns {*} {IndyLedgerJSON[]} - An array of Indy ledgers read from the file.
|
|
122
|
+
*/
|
|
123
|
+
export function readIndyLedgersFromFile(fileSystem, filePath) {
|
|
124
|
+
try {
|
|
125
|
+
if (!filePath.endsWith('.json')) {
|
|
126
|
+
throw new Error('File path must point to a JSON file');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Convert to absolute path ie: ./ledgers.json -> /Users/username/project/ledgers.json
|
|
130
|
+
const absoluteFilePath = fileSystem.pathResolve(filePath);
|
|
131
|
+
const jsonContent = fileSystem.readFile(absoluteFilePath);
|
|
132
|
+
return JSON.parse(jsonContent);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
throw new Error(`${ERROR_TAG}: Failed to read ledgers from file ${filePath}: ${error.message}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["axios","INDY_NETWORK_URL","ERROR_TAG","IndyLedger","_fetchUrlContent","url","response","get","data","error","Error","message","getIndyLedgers","indyLedgerConfigs","length","allIndyLedgers","ledgers","ledgerConfig","indyLedger","ledgerId","name","split","filter","word","test","join","push","id","indyNamespace","isProduction","connectOnStartup","doNotConnectOnStartup","genesisTransactions","genesisUrl","genesisPromises","map","ledger","Promise","all","forEach","transactions","index","trim","writeIndyLedgersToFile","fileSystem","filePath","endsWith","fileExists","JSON","stringify","readIndyLedgersFromFile","jsonContent","absoluteFilePath","pathResolve","writ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UAAU,EAAEC,QAAQ,CAAC,CAAC,KAAKG,IAAI,CAACC,SAAS,CAACjC,OAAO,CAAC,EACzF;MACA;IACF;IAEA,MAAMmC,WAAW,GAAGH,IAAI,CAACC,SAAS,CAACjC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;;IAEpD;IACA,MAAMoC,gBAAgB,GAAGR,UAAU,CAACS,WAAW,CAACR,QAAQ,CAAC;IACzDD,UAAU,CAACU,SAAS,CAACF,gBAAgB,EAAED,WAAW,CAAC;EACrD,CAAC,CAAC,OAAO1C,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAC,GAAGR,SAAS,qCAAqC2C,QAAQ,KAAKpC,KAAK,CAACE,OAAO,EAAE,CAAC;EAChG;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASuC,uBAAuBA,CAACN,UAAgC,EAAEC,QAAgB,EAAoB;EAC5G,IAAI;IACF,IAAI,CAACA,QAAQ,CAACC,QAAQ,CAAC,OAAO,CAAC,EAAE;MAC/B,MAAM,IAAIpC,KAAK,CAAC,qCAAqC,CAAC;IACxD;;IAEA;IACA,MAAM0C,gBAAgB,GAAGR,UAAU,CAACS,WAAW,CAACR,QAAQ,CAAC;IACzD,MAAMM,WAAW,GAAGP,UAAU,CAACW,QAAQ,CAACH,gBAAgB,CAAC;IAEzD,OAAOJ,IAAI,CAACQ,KAAK,CAACL,WAAW,CAAC;EAChC,CAAC,CAAC,OAAO1C,KAAU,EAAE;IACnB,MAAM,IAAIC,KAAK,CAAC,GAAGR,SAAS,sCAAsC2C,QAAQ,KAAKpC,KAAK,CAACE,OAAO,EAAE,CAAC;EACjG;AACF","ignoreList":[]}
|
|
@@ -93,6 +93,8 @@ export { createLinkSecretIfRequired, getAgentModules } from './utils/agent';
|
|
|
93
93
|
export { removeExistingInvitationsById, connectFromScanOrDeepLink, formatTime, useCredentialConnectionLabel, getConnectionName, } from './utils/helpers';
|
|
94
94
|
export { isValidAnonCredsCredential, getCredentialIdentifiers } from './utils/credential';
|
|
95
95
|
export { buildFieldsFromAnonCredsCredential } from './utils/oca';
|
|
96
|
+
export { IndyLedger, getIndyLedgers, readIndyLedgersFromFile, writeIndyLedgersToFile } from './utils/ledger';
|
|
97
|
+
export type { IndyLedgerConfig, IndyLedgerJSON, IndyLedgersRecord, IndyLedgerFileSystem } from './utils/ledger';
|
|
96
98
|
export type { AnimatedComponents } from './animated-components';
|
|
97
99
|
export type { ISVGAssets, ISpacing, IFontAttributes, IInputAttributes, IInlineInputMessage, IInputs, ITextTheme, ITabTheme, IBrandColors, ISemanticColors, INotificationColors, IErrorColors, IGrayscaleColors, IColorPalette, IAssets, ITheme, } from './theme';
|
|
98
100
|
export type { basicMessageCustomMetadata, credentialCustomMetadata } from './types/metadata';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,aAAa,MAAM,uBAAuB,CAAA;AAEjD,OAAO,SAAS,MAAM,OAAO,CAAA;AAC7B,OAAO,KAAK,UAAU,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACjG,OAAO,UAAU,EAAE,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,WAAW,MAAM,iCAAiC,CAAA;AACzD,OAAO,WAAW,MAAM,iCAAiC,CAAA;AACzD,OAAO,eAAe,MAAM,mCAAmC,CAAA;AAC/D,OAAO,cAAc,MAAM,kCAAkC,CAAA;AAC7D,OAAO,oBAAoB,MAAM,iCAAiC,CAAA;AAClE,OAAO,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,2BAA2B,C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,UAAU,EACV,cAAc,EACd,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,OAAO,EACP,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,8BAA8B,EAC9B,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,MAAM,EACN,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,OAAO,EACP,eAAe,EACf,cAAc,IAAI,eAAe,EACjC,QAAQ,EACR,cAAc,EACd,MAAM,EACN,IAAI,EACJ,UAAU,EACV,KAAK,EACL,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,YAAY,GACb,CAAA;AACD,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { IndyVdrPoolConfig } from '@credo-ts/indy-vdr';
|
|
2
|
+
export declare enum IndyLedger {
|
|
3
|
+
SOVRIN_BUILDER_NET = "sbn",
|
|
4
|
+
SOVRIN_STAGING_NET = "ssn",
|
|
5
|
+
SOVERIN_MAIN_NET = "smn",
|
|
6
|
+
LOCAL_VON_NETWORK = "vn",
|
|
7
|
+
LINUX_LOCAL_VON_NETWORK = "lln",
|
|
8
|
+
BCOVRIN_DEV = "bcd",
|
|
9
|
+
BCOVRIN_TEST = "bct",
|
|
10
|
+
BCOVRIN = "bcp",
|
|
11
|
+
GREENLIGHT_DEV_LEDGER = "gld",
|
|
12
|
+
INDICO_MAINNET = "imn",
|
|
13
|
+
INDICO_DEMONET = "idn",
|
|
14
|
+
INDICO_TESTNET = "itn",
|
|
15
|
+
CANDY_DEV_NETWORK = "cdn",
|
|
16
|
+
CANDY_TEST_NETWORK = "ctn",
|
|
17
|
+
CANDY_PRODUCTION_NETWORK = "cpn"
|
|
18
|
+
}
|
|
19
|
+
export interface IndyLedgerConfig {
|
|
20
|
+
ledgerId: IndyLedger;
|
|
21
|
+
isProduction: boolean;
|
|
22
|
+
doNotConnectOnStartup?: true;
|
|
23
|
+
}
|
|
24
|
+
export interface IndyLedgerJSON extends IndyVdrPoolConfig {
|
|
25
|
+
id: string;
|
|
26
|
+
}
|
|
27
|
+
export type IndyLedgersRecord = Record<IndyLedger, {
|
|
28
|
+
name: string;
|
|
29
|
+
indyNamespace: string;
|
|
30
|
+
genesisUrl: string;
|
|
31
|
+
}>;
|
|
32
|
+
export interface IndyLedgerFileSystem {
|
|
33
|
+
/**
|
|
34
|
+
* Writes data to a file at the specified file path.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} filePath - The path to the file where data should be written.
|
|
37
|
+
* @param {*} {string} data - The data to write to the file.
|
|
38
|
+
* @returns {*} {void}
|
|
39
|
+
*/
|
|
40
|
+
writeFile: (filePath: string, data: string) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Reads and returns the content of a file at the specified file path.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} filePath - The path to the file to read.
|
|
45
|
+
* @returns {*} {string} - The content of the file as a string.
|
|
46
|
+
*/
|
|
47
|
+
readFile: (filePath: string) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a file exists at the specified file path.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} filePath - The path to the file to check.
|
|
52
|
+
* @returns {*} {boolean} - True if the file exists, false otherwise.
|
|
53
|
+
*/
|
|
54
|
+
fileExists: (filePath: string) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Resolves and returns the absolute path for a given file path.
|
|
57
|
+
*
|
|
58
|
+
* @example ./ledgers.json -> /Users/username/project/ledgers.json
|
|
59
|
+
*
|
|
60
|
+
* @param {string} filePath - The file path to resolve.
|
|
61
|
+
* @returns {*} {string} - The resolved absolute file path.
|
|
62
|
+
*/
|
|
63
|
+
pathResolve: (filePath: string) => string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Fetches the content from a given URL and returns it as a Promise.
|
|
67
|
+
*
|
|
68
|
+
* @throws {Error} - Throws an error if the fetch operation fails.
|
|
69
|
+
* @template T - The type of content expected from the URL.
|
|
70
|
+
* @param {string} url - The URL to fetch content from.
|
|
71
|
+
* @returns {*} {Promise<T>} - A promise that resolves to the content fetched from the URL
|
|
72
|
+
*/
|
|
73
|
+
export declare function _fetchUrlContent<T>(url: string): Promise<T>;
|
|
74
|
+
/**
|
|
75
|
+
* Fetches and returns a list of Indy ledgers based on the provided configurations.
|
|
76
|
+
*
|
|
77
|
+
* @throws {Error} - Throws an error if a ledgerConfig is not found in the IndyLedgersRecord.
|
|
78
|
+
* @param {IndyLedgerConfig[]} indyLedgerConfigs - The list of supported Indy ledger configurations.
|
|
79
|
+
* @returns {*} {Promise<IndyLedgerJSON[]>} - A promise that resolves to an array of ledgers.
|
|
80
|
+
*/
|
|
81
|
+
export declare function getIndyLedgers(indyLedgerConfigs: IndyLedgerConfig[]): Promise<IndyLedgerJSON[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Writes the provided Indy ledgers to a JSON file at the specified file path.
|
|
84
|
+
*
|
|
85
|
+
* @throws {Error} - Throws an error if writing to the file fails or if the file path is invalid.
|
|
86
|
+
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for writing the file.
|
|
87
|
+
* @param {string} filePath - The path to the JSON file where the ledgers should be written.
|
|
88
|
+
* @param {IndyLedgerJSON[]} ledgers - The array of Indy ledgers to write to the file.
|
|
89
|
+
* @returns {*} {void}
|
|
90
|
+
*/
|
|
91
|
+
export declare function writeIndyLedgersToFile(fileSystem: IndyLedgerFileSystem, filePath: string, ledgers: IndyLedgerJSON[]): void;
|
|
92
|
+
/**
|
|
93
|
+
* Reads and parses Indy ledgers from a JSON file at the specified file path.
|
|
94
|
+
*
|
|
95
|
+
* @throws {Error} - Throws an error if reading from the file fails, if the file path is invalid, or if parsing fails.
|
|
96
|
+
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for reading the file.
|
|
97
|
+
* @param {string} filePath - The path to the JSON file to read the ledgers from.
|
|
98
|
+
* @returns {*} {IndyLedgerJSON[]} - An array of Indy ledgers read from the file.
|
|
99
|
+
*/
|
|
100
|
+
export declare function readIndyLedgersFromFile(fileSystem: IndyLedgerFileSystem, filePath: string): IndyLedgerJSON[];
|
|
101
|
+
//# sourceMappingURL=ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../../../src/utils/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAQtD,oBAAY,UAAU;IACpB,kBAAkB,QAAQ;IAC1B,kBAAkB,QAAQ;IAC1B,gBAAgB,QAAQ;IACxB,iBAAiB,OAAO;IACxB,uBAAuB,QAAQ;IAC/B,WAAW,QAAQ;IACnB,YAAY,QAAQ;IACpB,OAAO,QAAQ;IACf,qBAAqB,QAAQ;IAC7B,cAAc,QAAQ;IACtB,cAAc,QAAQ;IACtB,cAAc,QAAQ;IACtB,iBAAiB,QAAQ;IACzB,kBAAkB,QAAQ;IAC1B,wBAAwB,QAAQ;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,UAAU,CAAA;IACpB,YAAY,EAAE,OAAO,CAAA;IACrB,qBAAqB,CAAC,EAAE,IAAI,CAAA;CAC7B;AAED,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IAGvD,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CACpC,UAAU,EACV;IACE,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;CACnB,CACF,CAAA;AAID,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnD;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;IACtC;;;;;OAKG;IACH,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAA;IACzC;;;;;;;OAOG;IACH,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;CAC1C;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAOjE;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CA2CrG;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,oBAAoB,EAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,EAAE,GACxB,IAAI,CAsBN;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,CAc5G"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bifold/core",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.5",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/core": "~7.22.20",
|
|
35
35
|
"@babel/runtime": "~7.23.9",
|
|
36
|
-
"@bifold/oca": "2.4.
|
|
37
|
-
"@bifold/verifier": "2.4.
|
|
36
|
+
"@bifold/oca": "2.4.5",
|
|
37
|
+
"@bifold/verifier": "2.4.5",
|
|
38
38
|
"@commitlint/cli": "~11.0.0",
|
|
39
39
|
"@credo-ts/anoncreds": "0.5.13",
|
|
40
40
|
"@credo-ts/askar": "0.5.13",
|
package/src/index.ts
CHANGED
|
@@ -103,7 +103,9 @@ export {
|
|
|
103
103
|
} from './utils/helpers'
|
|
104
104
|
export { isValidAnonCredsCredential, getCredentialIdentifiers } from './utils/credential'
|
|
105
105
|
export { buildFieldsFromAnonCredsCredential } from './utils/oca'
|
|
106
|
+
export { IndyLedger, getIndyLedgers, readIndyLedgersFromFile, writeIndyLedgersToFile } from './utils/ledger'
|
|
106
107
|
|
|
108
|
+
export type { IndyLedgerConfig, IndyLedgerJSON, IndyLedgersRecord, IndyLedgerFileSystem } from './utils/ledger'
|
|
107
109
|
export type { AnimatedComponents } from './animated-components'
|
|
108
110
|
export type {
|
|
109
111
|
ISVGAssets,
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { IndyVdrPoolConfig } from '@credo-ts/indy-vdr'
|
|
2
|
+
import axios from 'axios'
|
|
3
|
+
|
|
4
|
+
const INDY_NETWORK_URL =
|
|
5
|
+
'https://raw.githubusercontent.com/hyperledger/indy-node-monitor/main/fetch-validator-status/networks.json'
|
|
6
|
+
|
|
7
|
+
const ERROR_TAG = 'LEDGER ERROR'
|
|
8
|
+
|
|
9
|
+
export enum IndyLedger {
|
|
10
|
+
SOVRIN_BUILDER_NET = 'sbn',
|
|
11
|
+
SOVRIN_STAGING_NET = 'ssn',
|
|
12
|
+
SOVERIN_MAIN_NET = 'smn',
|
|
13
|
+
LOCAL_VON_NETWORK = 'vn',
|
|
14
|
+
LINUX_LOCAL_VON_NETWORK = 'lln',
|
|
15
|
+
BCOVRIN_DEV = 'bcd',
|
|
16
|
+
BCOVRIN_TEST = 'bct',
|
|
17
|
+
BCOVRIN = 'bcp',
|
|
18
|
+
GREENLIGHT_DEV_LEDGER = 'gld',
|
|
19
|
+
INDICO_MAINNET = 'imn',
|
|
20
|
+
INDICO_DEMONET = 'idn',
|
|
21
|
+
INDICO_TESTNET = 'itn',
|
|
22
|
+
CANDY_DEV_NETWORK = 'cdn',
|
|
23
|
+
CANDY_TEST_NETWORK = 'ctn',
|
|
24
|
+
CANDY_PRODUCTION_NETWORK = 'cpn',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface IndyLedgerConfig {
|
|
28
|
+
ledgerId: IndyLedger
|
|
29
|
+
isProduction: boolean
|
|
30
|
+
doNotConnectOnStartup?: true
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface IndyLedgerJSON extends IndyVdrPoolConfig {
|
|
34
|
+
// A human-readable identifier for the ledger, useful for identifing the ledger in the JSON file.
|
|
35
|
+
// Note: This value will not be used downstream as the IndyVdrPoolConfig interface will exclude it.
|
|
36
|
+
id: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type IndyLedgersRecord = Record<
|
|
40
|
+
IndyLedger,
|
|
41
|
+
{
|
|
42
|
+
name: string
|
|
43
|
+
indyNamespace: string
|
|
44
|
+
genesisUrl: string
|
|
45
|
+
}
|
|
46
|
+
>
|
|
47
|
+
|
|
48
|
+
// This interface allows us to abstract the file system operations,
|
|
49
|
+
// preventing android from complaining about the use of the Node.js module 'fs'.
|
|
50
|
+
export interface IndyLedgerFileSystem {
|
|
51
|
+
/**
|
|
52
|
+
* Writes data to a file at the specified file path.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} filePath - The path to the file where data should be written.
|
|
55
|
+
* @param {*} {string} data - The data to write to the file.
|
|
56
|
+
* @returns {*} {void}
|
|
57
|
+
*/
|
|
58
|
+
writeFile: (filePath: string, data: string) => void
|
|
59
|
+
/**
|
|
60
|
+
* Reads and returns the content of a file at the specified file path.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} filePath - The path to the file to read.
|
|
63
|
+
* @returns {*} {string} - The content of the file as a string.
|
|
64
|
+
*/
|
|
65
|
+
readFile: (filePath: string) => string
|
|
66
|
+
/**
|
|
67
|
+
* Checks if a file exists at the specified file path.
|
|
68
|
+
*
|
|
69
|
+
* @param {string} filePath - The path to the file to check.
|
|
70
|
+
* @returns {*} {boolean} - True if the file exists, false otherwise.
|
|
71
|
+
*/
|
|
72
|
+
fileExists: (filePath: string) => boolean
|
|
73
|
+
/**
|
|
74
|
+
* Resolves and returns the absolute path for a given file path.
|
|
75
|
+
*
|
|
76
|
+
* @example ./ledgers.json -> /Users/username/project/ledgers.json
|
|
77
|
+
*
|
|
78
|
+
* @param {string} filePath - The file path to resolve.
|
|
79
|
+
* @returns {*} {string} - The resolved absolute file path.
|
|
80
|
+
*/
|
|
81
|
+
pathResolve: (filePath: string) => string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Fetches the content from a given URL and returns it as a Promise.
|
|
86
|
+
*
|
|
87
|
+
* @throws {Error} - Throws an error if the fetch operation fails.
|
|
88
|
+
* @template T - The type of content expected from the URL.
|
|
89
|
+
* @param {string} url - The URL to fetch content from.
|
|
90
|
+
* @returns {*} {Promise<T>} - A promise that resolves to the content fetched from the URL
|
|
91
|
+
*/
|
|
92
|
+
export async function _fetchUrlContent<T>(url: string): Promise<T> {
|
|
93
|
+
try {
|
|
94
|
+
const response = await axios.get<T>(url)
|
|
95
|
+
return response.data
|
|
96
|
+
} catch (error: any) {
|
|
97
|
+
throw new Error(`${ERROR_TAG}: Failed to fetch content from URL ${url}: ${error.message}`)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Fetches and returns a list of Indy ledgers based on the provided configurations.
|
|
103
|
+
*
|
|
104
|
+
* @throws {Error} - Throws an error if a ledgerConfig is not found in the IndyLedgersRecord.
|
|
105
|
+
* @param {IndyLedgerConfig[]} indyLedgerConfigs - The list of supported Indy ledger configurations.
|
|
106
|
+
* @returns {*} {Promise<IndyLedgerJSON[]>} - A promise that resolves to an array of ledgers.
|
|
107
|
+
*/
|
|
108
|
+
export async function getIndyLedgers(indyLedgerConfigs: IndyLedgerConfig[]): Promise<IndyLedgerJSON[]> {
|
|
109
|
+
if (!indyLedgerConfigs.length) {
|
|
110
|
+
return []
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const allIndyLedgers = await _fetchUrlContent<IndyLedgersRecord>(INDY_NETWORK_URL)
|
|
114
|
+
|
|
115
|
+
const ledgers: IndyLedgerJSON[] = []
|
|
116
|
+
// Iterate through the supported network configs and map them to the Indy ledgers
|
|
117
|
+
for (const ledgerConfig of indyLedgerConfigs) {
|
|
118
|
+
const indyLedger = allIndyLedgers[ledgerConfig.ledgerId]
|
|
119
|
+
|
|
120
|
+
if (!indyLedger) {
|
|
121
|
+
throw new Error(`${ERROR_TAG}: Ledger config for ${ledgerConfig.ledgerId} not found`)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const ledgerId = indyLedger.name
|
|
125
|
+
.split(' ')
|
|
126
|
+
.filter((word) => !/\W+/im.test(word))
|
|
127
|
+
.join('')
|
|
128
|
+
|
|
129
|
+
ledgers.push({
|
|
130
|
+
id: ledgerId,
|
|
131
|
+
indyNamespace: indyLedger.indyNamespace,
|
|
132
|
+
isProduction: ledgerConfig.isProduction,
|
|
133
|
+
connectOnStartup: !ledgerConfig.doNotConnectOnStartup,
|
|
134
|
+
// This url will need to be fetched to get the genesis transactions
|
|
135
|
+
genesisTransactions: indyLedger.genesisUrl,
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Step 1: Collect all genesis transaction promises
|
|
140
|
+
const genesisPromises = ledgers.map((ledger) => _fetchUrlContent<string>(ledger.genesisTransactions))
|
|
141
|
+
|
|
142
|
+
// Step 2: Await all promises to resolve in parallel
|
|
143
|
+
const genesisTransactions = await Promise.all(genesisPromises)
|
|
144
|
+
|
|
145
|
+
// Step 3: Assign the fetched genesis transactions back to the ledgers
|
|
146
|
+
genesisTransactions.forEach((transactions, index) => {
|
|
147
|
+
ledgers[index].genesisTransactions = transactions.trim()
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
return ledgers
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Writes the provided Indy ledgers to a JSON file at the specified file path.
|
|
155
|
+
*
|
|
156
|
+
* @throws {Error} - Throws an error if writing to the file fails or if the file path is invalid.
|
|
157
|
+
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for writing the file.
|
|
158
|
+
* @param {string} filePath - The path to the JSON file where the ledgers should be written.
|
|
159
|
+
* @param {IndyLedgerJSON[]} ledgers - The array of Indy ledgers to write to the file.
|
|
160
|
+
* @returns {*} {void}
|
|
161
|
+
*/
|
|
162
|
+
export function writeIndyLedgersToFile(
|
|
163
|
+
fileSystem: IndyLedgerFileSystem,
|
|
164
|
+
filePath: string,
|
|
165
|
+
ledgers: IndyLedgerJSON[]
|
|
166
|
+
): void {
|
|
167
|
+
try {
|
|
168
|
+
if (!filePath.endsWith('.json')) {
|
|
169
|
+
throw new Error('File path must point to a JSON file')
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Skip writing to file if the new ledgers are the same
|
|
173
|
+
if (
|
|
174
|
+
fileSystem.fileExists(filePath) &&
|
|
175
|
+
JSON.stringify(readIndyLedgersFromFile(fileSystem, filePath)) === JSON.stringify(ledgers)
|
|
176
|
+
) {
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const jsonContent = JSON.stringify(ledgers, null, 2)
|
|
181
|
+
|
|
182
|
+
// Convert to absolute path ie: ./ledgers.json -> /Users/username/project/ledgers.json
|
|
183
|
+
const absoluteFilePath = fileSystem.pathResolve(filePath)
|
|
184
|
+
fileSystem.writeFile(absoluteFilePath, jsonContent)
|
|
185
|
+
} catch (error: any) {
|
|
186
|
+
throw new Error(`${ERROR_TAG}: Failed to write ledgers to file ${filePath}: ${error.message}`)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Reads and parses Indy ledgers from a JSON file at the specified file path.
|
|
192
|
+
*
|
|
193
|
+
* @throws {Error} - Throws an error if reading from the file fails, if the file path is invalid, or if parsing fails.
|
|
194
|
+
* @param {IndyLedgerFileSystem} fileSystem - The file system interface to use for reading the file.
|
|
195
|
+
* @param {string} filePath - The path to the JSON file to read the ledgers from.
|
|
196
|
+
* @returns {*} {IndyLedgerJSON[]} - An array of Indy ledgers read from the file.
|
|
197
|
+
*/
|
|
198
|
+
export function readIndyLedgersFromFile(fileSystem: IndyLedgerFileSystem, filePath: string): IndyLedgerJSON[] {
|
|
199
|
+
try {
|
|
200
|
+
if (!filePath.endsWith('.json')) {
|
|
201
|
+
throw new Error('File path must point to a JSON file')
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Convert to absolute path ie: ./ledgers.json -> /Users/username/project/ledgers.json
|
|
205
|
+
const absoluteFilePath = fileSystem.pathResolve(filePath)
|
|
206
|
+
const jsonContent = fileSystem.readFile(absoluteFilePath)
|
|
207
|
+
|
|
208
|
+
return JSON.parse(jsonContent)
|
|
209
|
+
} catch (error: any) {
|
|
210
|
+
throw new Error(`${ERROR_TAG}: Failed to read ledgers from file ${filePath}: ${error.message}`)
|
|
211
|
+
}
|
|
212
|
+
}
|