@credo-ts/askar-to-drizzle-storage-migration 0.6.0-alpha-20250930134336

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 ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2020-present Hyperledger Contributors.
190
+ Copyright 2021 Queen’s Printer for Ontario. Mostafa Youssef (https://github.com/MosCD3), Amit Padmani (https://github.com/nbAmit), Prasad Katkar (https://github.com/NB-PrasadKatkar), Mike Richardson (https://github.com/NB-MikeRichardson)
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ <p align="center">
2
+ <br />
3
+ <img
4
+ alt="Credo Logo"
5
+ src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png"
6
+ height="250px"
7
+ />
8
+ </p>
9
+ <h1 align="center"><b>Credo Askar to Drizzle Storage Migration Module</b></h1>
10
+ <p align="center">
11
+ <a
12
+ href="https://raw.githubusercontent.com/openwallet-foundation/credo-ts/main/LICENSE"
13
+ ><img
14
+ alt="License"
15
+ src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"
16
+ /></a>
17
+ <a href="https://www.typescriptlang.org/"
18
+ ><img
19
+ alt="typescript"
20
+ src="https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg"
21
+ /></a>
22
+ <a href="https://www.npmjs.com/package/@credo-ts/askar-to-drizzle-storage-migration"
23
+ ><img
24
+ alt="@credo-ts/askar-to-drizzle-storage-migration version"
25
+ src="https://img.shields.io/npm/v/@credo-ts/askar-to-drizzle-storage-migration"
26
+ /></a>
27
+
28
+ </p>
29
+ <br />
30
+
31
+ Credo Askar to Drizzle Storage migration provides migration from the Askar storage module to the Drizzle storage module.
@@ -0,0 +1,49 @@
1
+ import { Agent, AgentDependencies, Logger } from '@credo-ts/core';
2
+ import { AskarModule } from '@credo-ts/askar';
3
+ import { DrizzleStorageModule } from '@credo-ts/drizzle-storage';
4
+ import { TenantsModule } from '@credo-ts/tenants';
5
+ /**
6
+ * Migration class to move storage from Askar to Drizzle. Note that this does not migrate
7
+ * the KMS part of Askar (the keys), and only the normal record storage.
8
+ *
9
+ * No backups are created during the process. The askar store is only used for reading, the
10
+ * drizzle store is also used for writing. Ensure the drizzle target is empty when starting the
11
+ * migration.
12
+ *
13
+ * Note that if you were previously using `AskarMultiWalletDatabaseScheme.DatabasePerWallet`, that all storage will be moved
14
+ * to a single database. You can still keep using multiiple databases for the Askar storage, but Drizzle only supports
15
+ * a single database per main agent instance (including sub agents for tenants).
16
+ */
17
+ export declare class AskarToDrizzleStorageMigrator {
18
+ private drizzleModule;
19
+ private askarModule;
20
+ private agentDependencies;
21
+ private logger;
22
+ private skipMigrationforMissingAdapter;
23
+ private tenantsModule?;
24
+ private drizzleAgent;
25
+ askarAgent: Agent<import("@credo-ts/core").ModulesMap>;
26
+ private drizzleConfig;
27
+ private drizzleAdapters;
28
+ private constructor();
29
+ static initialize({ drizzleModule, askarModule, agentDependencies, logger, skipMigrationForMissingAdapter, tenantsModule, }: {
30
+ drizzleModule: DrizzleStorageModule;
31
+ askarModule: AskarModule;
32
+ agentDependencies: AgentDependencies;
33
+ logger: Logger;
34
+ tenantsModule?: TenantsModule;
35
+ /**
36
+ * When set to `true`, the migration of any records in the Askar store that don't
37
+ * have an adapter registered will be skipped. Note that this can be dangerous and
38
+ * result in loss of data in the new store. Use this only if you have records with a
39
+ * category in your askar store, for which there is no adapter registered, and should
40
+ * not be migrated.
41
+ *
42
+ * @default false
43
+ */
44
+ skipMigrationForMissingAdapter?: boolean;
45
+ }): Promise<AskarToDrizzleStorageMigrator>;
46
+ private getAdapterForRecordType;
47
+ migrate(): Promise<void>;
48
+ private migrateForContext;
49
+ }
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AskarToDrizzleStorageMigrator = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ const askar_1 = require("@credo-ts/askar");
6
+ const askar_2 = require("@credo-ts/askar");
7
+ const askar_3 = require("@credo-ts/askar");
8
+ const drizzle_storage_1 = require("@credo-ts/drizzle-storage");
9
+ const askar_shared_1 = require("@openwallet-foundation/askar-shared");
10
+ const AskarToDrizzleStorageMigrationError_1 = require("./errors/AskarToDrizzleStorageMigrationError");
11
+ /**
12
+ * Migration class to move storage from Askar to Drizzle. Note that this does not migrate
13
+ * the KMS part of Askar (the keys), and only the normal record storage.
14
+ *
15
+ * No backups are created during the process. The askar store is only used for reading, the
16
+ * drizzle store is also used for writing. Ensure the drizzle target is empty when starting the
17
+ * migration.
18
+ *
19
+ * Note that if you were previously using `AskarMultiWalletDatabaseScheme.DatabasePerWallet`, that all storage will be moved
20
+ * to a single database. You can still keep using multiiple databases for the Askar storage, but Drizzle only supports
21
+ * a single database per main agent instance (including sub agents for tenants).
22
+ */
23
+ class AskarToDrizzleStorageMigrator {
24
+ constructor(drizzleModule, askarModule, agentDependencies, logger, skipMigrationforMissingAdapter, tenantsModule) {
25
+ this.drizzleModule = drizzleModule;
26
+ this.askarModule = askarModule;
27
+ this.agentDependencies = agentDependencies;
28
+ this.logger = logger;
29
+ this.skipMigrationforMissingAdapter = skipMigrationforMissingAdapter;
30
+ this.tenantsModule = tenantsModule;
31
+ this.drizzleAgent = new core_1.Agent({
32
+ dependencies: this.agentDependencies,
33
+ config: {
34
+ logger: this.logger,
35
+ },
36
+ modules: this.tenantsModule
37
+ ? {
38
+ drizzle: this.drizzleModule,
39
+ tenants: this.tenantsModule,
40
+ }
41
+ : {
42
+ drizzle: this.drizzleModule,
43
+ },
44
+ });
45
+ this.askarAgent = new core_1.Agent({
46
+ modules: this.tenantsModule
47
+ ? {
48
+ askar: this.askarModule,
49
+ tenants: this.tenantsModule,
50
+ }
51
+ : {
52
+ askar: this.askarModule,
53
+ },
54
+ config: {
55
+ logger: this.logger,
56
+ },
57
+ dependencies: this.agentDependencies,
58
+ });
59
+ this.drizzleConfig = this.drizzleAgent.context.resolve(drizzle_storage_1.DrizzleStorageModuleConfig);
60
+ this.drizzleAdapters = this.drizzleConfig.adapters;
61
+ }
62
+ static async initialize({ drizzleModule, askarModule, agentDependencies, logger = new core_1.ConsoleLogger(core_1.LogLevel.trace), skipMigrationForMissingAdapter = false, tenantsModule, }) {
63
+ if (!askarModule.config.enableStorage) {
64
+ throw new AskarToDrizzleStorageMigrationError_1.AskarToDrizzleStorageMigrationError('Askar module has enableStorage set to false. Make sure the storage is enabled on the askar module');
65
+ }
66
+ const migrator = new AskarToDrizzleStorageMigrator(drizzleModule, askarModule, agentDependencies, logger, skipMigrationForMissingAdapter, tenantsModule);
67
+ return migrator;
68
+ }
69
+ getAdapterForRecordType(recordType) {
70
+ const adapter = this.drizzleAdapters.find((adapter) => adapter.recordClass.type === recordType);
71
+ if (!adapter) {
72
+ return null;
73
+ }
74
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
75
+ return adapter;
76
+ }
77
+ async migrate() {
78
+ try {
79
+ await this.drizzleAgent.initialize();
80
+ this.logger.info('Successfully initialized drizzle agent');
81
+ await this.askarAgent.initialize();
82
+ this.logger.info('Successfully initialized askar agent');
83
+ this.logger.info('Starting migration of default agent context');
84
+ await this.migrateForContext({
85
+ askarContext: this.askarAgent.context,
86
+ drizzleContext: this.drizzleAgent.context,
87
+ });
88
+ this.logger.info('Succesfully migrated default agent context');
89
+ if (this.tenantsModule) {
90
+ const askarAgentWithTenants = this.askarAgent;
91
+ const drizzleAgentWithTenants = this.drizzleAgent;
92
+ this.logger.info('Detected tenants module, migrating tenants context');
93
+ const allTenants = await askarAgentWithTenants.modules.tenants.getAllTenants();
94
+ this.logger.debug(`Retrieved '${allTenants.length}' tenant records to migrate.`);
95
+ for (const tenant of allTenants) {
96
+ this.logger.info(`Starting migration of tenant '${tenant.id}'`);
97
+ // NOTE: we create a nested withTenantAgent, as we need to have the context for both the askar and drizzle module/agent.
98
+ // Using `withTenantAgent` ensures the session is always correctly closed, so it's the safest way
99
+ await askarAgentWithTenants.modules.tenants.withTenantAgent({ tenantId: tenant.id }, async (askarTenantAgent) => {
100
+ await drizzleAgentWithTenants.modules.tenants.withTenantAgent({ tenantId: tenant.id }, (drizzleTenantAgent) => this.migrateForContext({
101
+ askarContext: askarTenantAgent.context,
102
+ drizzleContext: drizzleTenantAgent.context,
103
+ }));
104
+ });
105
+ this.logger.info(`Succesfully migrated tenant '${tenant.id}'`);
106
+ }
107
+ }
108
+ }
109
+ finally {
110
+ if (this.drizzleAgent.isInitialized) {
111
+ await this.drizzleAgent.shutdown();
112
+ }
113
+ if (this.askarAgent.isInitialized) {
114
+ await this.askarAgent.shutdown();
115
+ }
116
+ }
117
+ }
118
+ async migrateForContext({ drizzleContext, askarContext, }) {
119
+ try {
120
+ const storeManager = askarContext.resolve(askar_2.AskarStoreManager);
121
+ const askar = askarContext.resolve(askar_1.AskarModuleConfig).askar;
122
+ const { store, profile } = await storeManager.getInitializedStoreWithProfile(askarContext);
123
+ // We need to make sure that the drizzle storage is provisioned for the context
124
+ // In case of root agent context this will alreayd be handled on initialization
125
+ // but for tenants agents we need to make sure a row exists in the `Context` table
126
+ await this.drizzleModule.onProvisionContext(drizzleContext);
127
+ let scanHandle = undefined;
128
+ let entryListHandle = null;
129
+ let migratedRecordCount = 0;
130
+ let skippedRecordCount = 0;
131
+ const skippedRecordTypes = [];
132
+ try {
133
+ this.logger.debug(`Initializing retrieval of records from askar storage for context '${askarContext.contextCorrelationId}'`);
134
+ scanHandle = await askar.scanStart({
135
+ storeHandle: store.handle,
136
+ profile,
137
+ });
138
+ while (true) {
139
+ this.logger.debug(`Fetching batch of records from askar storage for context '${askarContext.contextCorrelationId}'`);
140
+ entryListHandle = await askar.scanNext({ scanHandle });
141
+ // We reached the end of the scan
142
+ if (!entryListHandle) {
143
+ this.logger.debug(`No records returned in batch from askar storage. No records left to migrate for context '${askarContext.contextCorrelationId}'`);
144
+ break;
145
+ }
146
+ const list = new askar_shared_1.EntryList({ handle: entryListHandle });
147
+ this.logger.debug(`Retrieved batch of '${list.length}' records from askar storage for context '${askarContext.contextCorrelationId}'`);
148
+ for (let index = 0; index < list.length; index++) {
149
+ const entry = list.getEntryByIndex(index);
150
+ const entryObject = entry.toJson();
151
+ this.logger.trace(`Retrieved record with index '${index}', id '${entryObject.name}' and type '${entryObject.category}' from batch for context '${askarContext.contextCorrelationId}'`);
152
+ const adapter = this.getAdapterForRecordType(entryObject.category);
153
+ if (!adapter) {
154
+ if (this.skipMigrationforMissingAdapter) {
155
+ this.logger.info(`Skippping migration of record '${entry.name}' with type '${entry.category}' due to missing drizzle adapter for context '${askarContext.contextCorrelationId}'.`);
156
+ skippedRecordCount++;
157
+ skippedRecordTypes.push(entryObject.category);
158
+ continue;
159
+ }
160
+ throw new AskarToDrizzleStorageMigrationError_1.AskarToDrizzleStorageMigrationError(`Could not find a registered drizzle adapter for record type '${entry.category}'. Make sure to register the record type in the DrizzleStorageModule.`);
161
+ }
162
+ const record = (0, askar_3.recordToInstance)(entryObject, adapter.recordClass);
163
+ if (record instanceof core_1.StorageVersionRecord && record.id === core_1.StorageVersionRecord.storageVersionRecordId) {
164
+ this.logger.debug(`Updating record '${record.id}' with type '${record.type}' into drizzle storage for context '${askarContext.contextCorrelationId}'`);
165
+ // A new storage version record is created when we first initialize the agent
166
+ // so in this case we need to update the record
167
+ await adapter.update(drizzleContext, record);
168
+ }
169
+ else {
170
+ this.logger.debug(`Inserting record '${record.id}' with type '${record.type}' into drizzle storage for context '${askarContext.contextCorrelationId}'`);
171
+ await adapter.insert(drizzleContext, record);
172
+ }
173
+ migratedRecordCount++;
174
+ }
175
+ this.logger.debug(`Processed all records from batch for context '${askarContext.contextCorrelationId}'`);
176
+ // Free and clear handle
177
+ entryListHandle.free();
178
+ entryListHandle = null;
179
+ }
180
+ this.logger.debug(`Succesfully migrated '${migratedRecordCount}' records from Askar to Drizzle for context '${askarContext.contextCorrelationId}'`, {
181
+ migratedRecordCount,
182
+ skippedRecordCount,
183
+ skippedRecordTypes,
184
+ });
185
+ }
186
+ finally {
187
+ // Free entry list handle if we didn't free it yet (in case of error)
188
+ entryListHandle?.free();
189
+ entryListHandle = null;
190
+ scanHandle?.free();
191
+ scanHandle = undefined;
192
+ }
193
+ }
194
+ catch (error) {
195
+ this.logger.error(`Migration failed for context '${askarContext.contextCorrelationId}'. ${error.message}`);
196
+ throw new AskarToDrizzleStorageMigrationError_1.AskarToDrizzleStorageMigrationError(`Migration failed for context '${askarContext.contextCorrelationId}'. ${error.message}`, {
197
+ cause: error,
198
+ });
199
+ }
200
+ }
201
+ }
202
+ exports.AskarToDrizzleStorageMigrator = AskarToDrizzleStorageMigrator;
203
+ //# sourceMappingURL=AskarToDrizzleStorageMigrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AskarToDrizzleStorageMigrator.js","sourceRoot":"","sources":["../src/AskarToDrizzleStorageMigrator.ts"],"names":[],"mappings":";;;AAAA,yCASuB;AAGvB,2CAAgE;AAChE,2CAAmD;AACnD,2CAAkD;AAClD,+DAAsH;AAEtH,sEAA2E;AAC3E,sGAAkG;AAElG;;;;;;;;;;;GAWG;AACH,MAAa,6BAA6B;IAkCxC,YACU,aAAmC,EACnC,WAAwB,EACxB,iBAAoC,EACpC,MAAc,EACd,8BAAuC,EACvC,aAA6B;QAL7B,kBAAa,GAAb,aAAa,CAAsB;QACnC,gBAAW,GAAX,WAAW,CAAa;QACxB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,WAAM,GAAN,MAAM,CAAQ;QACd,mCAA8B,GAA9B,8BAA8B,CAAS;QACvC,kBAAa,GAAb,aAAa,CAAgB;QAvC/B,iBAAY,GAAG,IAAI,YAAK,CAAC;YAC/B,YAAY,EAAE,IAAI,CAAC,iBAAiB;YACpC,MAAM,EAAE;gBACN,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB;YACD,OAAO,EAAE,IAAI,CAAC,aAAa;gBACzB,CAAC,CAAC;oBACE,OAAO,EA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are class AskarToDrizzleStorageMigrationError extends CredoError {
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AskarToDrizzleStorageMigrationError = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ /**
6
+ * @internal
7
+ */
8
+ class AskarToDrizzleStorageMigrationError extends core_1.CredoError {
9
+ }
10
+ exports.AskarToDrizzleStorageMigrationError = AskarToDrizzleStorageMigrationError;
11
+ //# sourceMappingURL=AskarToDrizzleStorageMigrationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AskarToDrizzleStorageMigrationError.js","sourceRoot":"","sources":["../../src/errors/AskarToDrizzleStorageMigrationError.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAE3C;;GAEG;AACH,MAAa,mCAAoC,SAAQ,iBAAU;CAAG;AAAtE,kFAAsE"}
@@ -0,0 +1 @@
1
+ export { AskarToDrizzleStorageMigrator } from './AskarToDrizzleStorageMigrator';
package/build/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AskarToDrizzleStorageMigrator = void 0;
4
+ var AskarToDrizzleStorageMigrator_1 = require("./AskarToDrizzleStorageMigrator");
5
+ Object.defineProperty(exports, "AskarToDrizzleStorageMigrator", { enumerable: true, get: function () { return AskarToDrizzleStorageMigrator_1.AskarToDrizzleStorageMigrator; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iFAA+E;AAAtE,8IAAA,6BAA6B,OAAA"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@credo-ts/askar-to-drizzle-storage-migration",
3
+ "main": "build/index",
4
+ "types": "build/index",
5
+ "version": "0.6.0-alpha-20250930134336",
6
+ "files": [
7
+ "build"
8
+ ],
9
+ "license": "Apache-2.0",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "homepage": "https://github.com/openwallet-foundation/credo-ts/tree/main/packages/askar-to-drizzle-storage-migration",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/openwallet-foundation/credo-ts",
17
+ "directory": "packages/askar-to-drizzle-storage-migration"
18
+ },
19
+ "dependencies": {
20
+ "@openwallet-foundation/askar-shared": "^0.4.1",
21
+ "@credo-ts/askar": "0.6.0-alpha-20250930134336",
22
+ "@credo-ts/drizzle-storage": "0.6.0-alpha-20250930134336",
23
+ "@credo-ts/core": "0.6.0-alpha-20250930134336"
24
+ },
25
+ "devDependencies": {
26
+ "rimraf": "^6.0.1",
27
+ "typescript": "~5.8.3"
28
+ },
29
+ "scripts": {
30
+ "build": "pnpm run clean && pnpm run compile",
31
+ "clean": "rimraf ./build",
32
+ "compile": "tsc -p tsconfig.build.json",
33
+ "test": "jest"
34
+ }
35
+ }