Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add more logging in patch #14

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .yarn/patches/@credo-ts-askar-npm-0.5.3-9992a6ea11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
diff --git a/build/utils/askarWalletConfig.js b/build/utils/askarWalletConfig.js
index 045773aa8100917aa1f794de59e3813e296a3c45..87e08f5a7288f4a0604321cf4e9db6ec844c588f 100644
--- a/build/utils/askarWalletConfig.js
+++ b/build/utils/askarWalletConfig.js
@@ -24,21 +24,29 @@ const uriFromWalletConfig = (walletConfig, credoDataPath) => {
let uri = '';
let path;
// By default use sqlite as database backend
+ console.log('uriFromWalletConfig walletConfig', walletConfig);
if (!walletConfig.storage) {
+ console.log('using sqlite as default');
walletConfig.storage = { type: 'sqlite' };
}
const urlParams = [];
const storageConfig = walletConfig.storage;
+ console.log('storageConfig', storageConfig)
if ((0, AskarWalletStorageConfig_1.isAskarWalletSqliteStorageConfig)(storageConfig)) {
if ((_a = storageConfig.config) === null || _a === void 0 ? void 0 : _a.inMemory) {
+ console.log('using inMemory');
uri = 'sqlite://:memory:';
}
else {
+ console.log('using path');
path = (_c = (_b = storageConfig.config) === null || _b === void 0 ? void 0 : _b.path) !== null && _c !== void 0 ? _c : `${credoDataPath}/wallet/${walletConfig.id}/sqlite.db`;
+ console.log('path:', path);
uri = `sqlite://${path}`;
+ console.log('uri:', uri);
}
}
else if ((0, AskarWalletStorageConfig_1.isAskarWalletPostgresStorageConfig)(storageConfig)) {
+ console.log('using postgres???????');
if (!storageConfig.config || !storageConfig.credentials) {
throw new core_1.WalletError('Invalid storage configuration for postgres wallet');
}
@@ -57,6 +65,7 @@ const uriFromWalletConfig = (walletConfig, credoDataPath) => {
uri = `postgres://${encodeURIComponent(storageConfig.credentials.account)}:${encodeURIComponent(storageConfig.credentials.password)}@${storageConfig.config.host}/${encodeURIComponent(walletConfig.id)}`;
}
else {
+ console.log('storage type not supported');
throw new core_1.WalletError(`Storage type not supported: ${storageConfig.type}`);
}
// Common config options
@@ -67,8 +76,10 @@ const uriFromWalletConfig = (walletConfig, credoDataPath) => {
urlParams.push(`min_connections=${encodeURIComponent(storageConfig.config.minConnections)}`);
}
if (urlParams.length > 0) {
+ console.log('urlParams:', urlParams);
uri = `${uri}?${urlParams.join('&')}`;
}
+ console.log('final uri:', uri);
return { uri, path };
};
exports.uriFromWalletConfig = uriFromWalletConfig;
diff --git a/build/wallet/AskarWallet.js b/build/wallet/AskarWallet.js
index 4172e9577dc09f0a51886171d44934a0315ded37..82bf81f575260cbf680703b1ef908b2bc3f2c0af 100644
--- a/build/wallet/AskarWallet.js
+++ b/build/wallet/AskarWallet.js
@@ -66,11 +66,16 @@ let AskarWallet = class AskarWallet extends AskarBaseWallet_1.AskarBaseWallet {
* @throws {WalletError} if another error occurs
*/
async createAndOpen(walletConfig) {
- this.logger.debug(`Creating wallet '${walletConfig.id}`);
+ this.logger.debug(`Creating wallet '${walletConfig.id}'`);
+ console.log('walletConfig', walletConfig);
+ console.log('JSON.stringify(walletConfig)', JSON.stringify(walletConfig));
const askarWalletConfig = await this.getAskarWalletConfig(walletConfig);
// Check if database exists
const { path: filePath } = (0, utils_1.uriFromWalletConfig)(walletConfig, this.fileSystem.dataPath);
+ console.log('filePath:', filePath);
+ console.log('await this.fileSystem.exists(filePath):', await this.fileSystem.exists(filePath));
if (filePath && (await this.fileSystem.exists(filePath))) {
+ console.log('DUPLICATE')
throw new core_1.WalletDuplicateError(`Wallet '${walletConfig.id}' already exists.`, {
walletType: 'AskarWallet',
});
@@ -78,8 +83,12 @@ let AskarWallet = class AskarWallet extends AskarBaseWallet_1.AskarBaseWallet {
try {
// Make sure path exists before creating the wallet
if (filePath) {
+ console.log('creating dir:')
await this.fileSystem.createDirectory(filePath);
+ console.log('successfully created dir:')
}
+ console.log('askarWalletConfig:', askarWalletConfig);
+ console.log('JSON.stringify(askarWalletConfig):', JSON.stringify(askarWalletConfig));
this._store = await aries_askar_shared_1.Store.provision({
recreate: false,
uri: askarWalletConfig.uri,
@@ -92,10 +101,13 @@ let AskarWallet = class AskarWallet extends AskarBaseWallet_1.AskarBaseWallet {
this.walletConfig = walletConfig;
}
catch (error) {
+ console.log('ERROR:', error)
+ console.log('error.message:', error?.message)
// FIXME: Askar should throw a Duplicate error code, but is currently returning Encryption
// And if we provide the very same wallet key, it will open it without any error
if ((0, utils_1.isAskarError)(error) &&
(error.code === utils_1.AskarErrorCode.Encryption || error.code === utils_1.AskarErrorCode.Duplicate)) {
+ console.log('DUPLICATE OR ENCRYPTION')
const errorMessage = `Wallet '${walletConfig.id}' already exists`;
this.logger.debug(errorMessage);
throw new core_1.WalletDuplicateError(errorMessage, {
@@ -322,6 +334,10 @@ let AskarWallet = class AskarWallet extends AskarBaseWallet_1.AskarBaseWallet {
async getAskarWalletConfig(walletConfig) {
var _a;
const { uri, path } = (0, utils_1.uriFromWalletConfig)(walletConfig, this.fileSystem.dataPath);
+ console.log('uri:', uri);
+ console.log('path:', path);
+ console.log('profile:', walletConfig.id);
+ console.log('passKey:', walletConfig.key);
return {
uri,
path,
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FROM builder AS runner

# Create a volume for the Credo agent data, allow read write access
RUN mkdir /var/credo && \
chmod -R 2777 /var/credo
chmod 777 /var/credo

# Expose port
EXPOSE 3000
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@credo-ts/anoncreds": "0.5.3",
"@credo-ts/askar": "0.5.3",
"@credo-ts/askar": "patch:@credo-ts/askar@npm%3A0.5.3#~/.yarn/patches/@credo-ts-askar-npm-0.5.3-9992a6ea11.patch",
"@credo-ts/core": "0.5.3",
"@credo-ts/indy-vdr": "0.5.3",
"@credo-ts/node": "0.5.3",
Expand Down Expand Up @@ -82,5 +82,8 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"packageManager": "yarn@4.3.1"
"packageManager": "yarn@4.3.1",
"resolutions": {
"@credo-ts/askar@npm:0.5.3": "patch:@credo-ts/askar@npm%3A0.5.3#~/.yarn/patches/@credo-ts-askar-npm-0.5.3-9992a6ea11.patch"
}
}
18 changes: 17 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,22 @@ __metadata:
languageName: node
linkType: hard

"@credo-ts/askar@patch:@credo-ts/askar@npm%3A0.5.3#~/.yarn/patches/@credo-ts-askar-npm-0.5.3-9992a6ea11.patch":
version: 0.5.3
resolution: "@credo-ts/askar@patch:@credo-ts/askar@npm%3A0.5.3#~/.yarn/patches/@credo-ts-askar-npm-0.5.3-9992a6ea11.patch::version=0.5.3&hash=f0d7e9"
dependencies:
"@credo-ts/core": "npm:0.5.3"
bn.js: "npm:^5.2.1"
class-transformer: "npm:0.5.1"
class-validator: "npm:0.14.1"
rxjs: "npm:^7.8.0"
tsyringe: "npm:^4.8.0"
peerDependencies:
"@hyperledger/aries-askar-shared": ^0.2.1
checksum: 10c0/44c0cfcb938171252cb8483034a7711f4ace5f3467fbd248e4b953ba7a7d38eec492e637a873aba473999f00973dc0b6a6a66e641e9d46776c648ed071a9f1dc
languageName: node
linkType: hard

"@credo-ts/core@npm:0.5.3":
version: 0.5.3
resolution: "@credo-ts/core@npm:0.5.3"
Expand Down Expand Up @@ -5592,7 +5608,7 @@ __metadata:
resolution: "indy-vdr-proxy-server@workspace:."
dependencies:
"@credo-ts/anoncreds": "npm:0.5.3"
"@credo-ts/askar": "npm:0.5.3"
"@credo-ts/askar": "patch:@credo-ts/askar@npm%3A0.5.3#~/.yarn/patches/@credo-ts-askar-npm-0.5.3-9992a6ea11.patch"
"@credo-ts/core": "npm:0.5.3"
"@credo-ts/indy-vdr": "npm:0.5.3"
"@credo-ts/node": "npm:0.5.3"
Expand Down
Loading