diff --git a/packages/docs/src/.vitepress/config.ts b/packages/docs/src/.vitepress/config.ts
index abda67e..4c0fb36 100644
--- a/packages/docs/src/.vitepress/config.ts
+++ b/packages/docs/src/.vitepress/config.ts
@@ -161,6 +161,14 @@ export default withMermaid({
link: '/tools/primitives#block-header',
},
{ text: 'Bytes', link: '/tools/primitives#bytes' },
+ {
+ text: 'Encrypter',
+ link: '/tools/primitives#encrypter',
+ },
+ {
+ text: 'Hasher',
+ link: '/tools/primitives#hasher',
+ },
{
text: 'HD Private Node',
link: '/tools/primitives#hd-private-node',
@@ -210,7 +218,6 @@ export default withMermaid({
},
],
},
- */
{
text: 'Utils',
link: '/tools/stack/utils',
@@ -222,6 +229,7 @@ export default withMermaid({
{ text: 'Hasher', link: '/tools/stack/utils#hasher' },
],
},
+ */
],
},
],
diff --git a/packages/docs/src/tools/primitive-functions.ts b/packages/docs/src/tools/primitive-functions.ts
index c5ee46f..158246e 100644
--- a/packages/docs/src/tools/primitive-functions.ts
+++ b/packages/docs/src/tools/primitive-functions.ts
@@ -4,8 +4,8 @@ import {
Bytes,
encodeExtendedJson,
decodeExtendedJson,
- // Encrypter,
- // Hasher,
+ Encrypter,
+ Hasher,
HDPrivateNode,
HDPublicNode,
Mnemonic,
@@ -204,6 +204,78 @@ export const bytes = {
],
};
+export const encrypter = {
+ from: [
+ {
+ label: 'From Passphrase',
+ inputs: ['Passphrase'],
+ models: [''],
+ callback: (args: [string]) => Encrypter.fromPassphrase(...args),
+ extendedInput: true,
+ },
+ ],
+ to: [],
+ methods: [
+ {
+ label: 'Encrypt',
+ inputs: ['UTF8'],
+ models: ['Your text here'],
+ callback: async (encrypter: Encrypter, args: [string]) =>
+ Bytes.fromBytes(await encrypter.encrypt(...args)).toHex(),
+ },
+ {
+ label: 'Decrypt',
+ inputs: ['Hex'],
+ models: ['Encrypted Data (hex)'],
+ callback: async (encrypter: Encrypter, args: [string]) =>
+ Bytes.fromBytes(
+ await encrypter.decrypt(Bytes.fromHex(...args).toBytes()),
+ ).toUtf8(),
+ },
+ ],
+};
+
+export const hasher = {
+ from: [
+ {
+ label: 'From Hex',
+ inputs: ['Hex'],
+ models: [''],
+ callback: (args: [string]) => Hasher.fromHex(...args),
+ },
+ {
+ label: 'From Base64',
+ inputs: ['Base64'],
+ models: [''],
+ callback: (args: [string]) => Hasher.fromBase64(...args),
+ },
+ {
+ label: 'From UTF-8',
+ inputs: ['UTF-8'],
+ models: [''],
+ callback: (args: [string]) => Hasher.fromUTF8(...args),
+ },
+ ],
+ to: [
+ {
+ label: 'To Sha256 Hex',
+ callback: (hasher: Hasher) => hasher.toSHA256Hex(),
+ },
+ {
+ label: 'To RipeMD160 Hex',
+ callback: (hasher: Hasher) => hasher.toRIPEMD160Hex(),
+ },
+ {
+ label: 'To Hash160 Hex',
+ callback: (hasher: Hasher) => hasher.toHash160Hex(),
+ },
+ {
+ label: 'To Hash256 Hex',
+ callback: (hasher: Hasher) => hasher.toHash256Hex(),
+ },
+ ],
+};
+
export const hdPrivateNode = {
from: [
{
diff --git a/packages/docs/src/tools/primitives.md b/packages/docs/src/tools/primitives.md
index 6dfa0e6..c801881 100644
--- a/packages/docs/src/tools/primitives.md
+++ b/packages/docs/src/tools/primitives.md
@@ -10,6 +10,8 @@ import {
address,
blockHeader,
bytes,
+ encrypter,
+ hasher,
hdPrivateNode,
hdPublicNode,
mnemonic,
@@ -65,6 +67,31 @@ Note that these are still unstable and will change in future.
/>
+## Encrypter
+
+
+
+## Hasher
+
+
+
## HD Private Node
diff --git a/packages/docs/src/tools/stack/utils-functions.ts b/packages/docs/src/tools/stack/utils-functions.ts
deleted file mode 100644
index 94419a2..0000000
--- a/packages/docs/src/tools/stack/utils-functions.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { Bytes } from '@xocash/primitives';
-import { Encrypter, Hasher } from '@xocash/stack';
-
-export const encrypter = {
- from: [
- {
- label: 'From Passphrase',
- inputs: ['Passphrase'],
- models: [''],
- callback: (args: [string]) => Encrypter.fromPassphrase(...args),
- extendedInput: true,
- },
- ],
- to: [],
- methods: [
- {
- label: 'Encrypt',
- inputs: ['UTF8'],
- models: ['Your text here'],
- callback: async (encrypter: Encrypter, args: [string]) =>
- Bytes.fromBytes(await encrypter.encrypt(...args)).toHex(),
- },
- {
- label: 'Decrypt',
- inputs: ['Hex'],
- models: ['Encrypted Data (hex)'],
- callback: async (encrypter: Encrypter, args: [string]) =>
- Bytes.fromBytes(
- await encrypter.decrypt(Bytes.fromHex(...args).toBytes()),
- ).toUtf8(),
- },
- ],
-};
-
-export const hasher = {
- from: [
- {
- label: 'From Hex',
- inputs: ['Hex'],
- models: [''],
- callback: (args: [string]) => Hasher.fromHex(...args),
- },
- {
- label: 'From Base64',
- inputs: ['Base64'],
- models: [''],
- callback: (args: [string]) => Hasher.fromBase64(...args),
- },
- {
- label: 'From UTF-8',
- inputs: ['UTF-8'],
- models: [''],
- callback: (args: [string]) => Hasher.fromUTF8(...args),
- },
- ],
- to: [
- {
- label: 'To Sha256 Hex',
- callback: (hasher: Hasher) => hasher.toSHA256Hex(),
- },
- {
- label: 'To RipeMD160 Hex',
- callback: (hasher: Hasher) => hasher.toRIPEMD160Hex(),
- },
- {
- label: 'To Hash160 Hex',
- callback: (hasher: Hasher) => hasher.toHash160Hex(),
- },
- {
- label: 'To Hash256 Hex',
- callback: (hasher: Hasher) => hasher.toHash256Hex(),
- },
- ],
-};
diff --git a/packages/docs/src/tools/stack/utils.md b/packages/docs/src/tools/stack/utils.md
deleted file mode 100644
index f4bcfb2..0000000
--- a/packages/docs/src/tools/stack/utils.md
+++ /dev/null
@@ -1,42 +0,0 @@
----
-aside: false
----
-
-
-
-
-
-# Utils
-
-## Encrypter
-
-
-
-## Hasher
-
-
diff --git a/packages/stack/src/utils/encrypter.ts b/packages/primitives/src/encrypter.ts
similarity index 100%
rename from packages/stack/src/utils/encrypter.ts
rename to packages/primitives/src/encrypter.ts
diff --git a/packages/stack/src/utils/hasher.ts b/packages/primitives/src/hasher.ts
similarity index 100%
rename from packages/stack/src/utils/hasher.ts
rename to packages/primitives/src/hasher.ts
diff --git a/packages/primitives/src/index.ts b/packages/primitives/src/index.ts
index 1fb176c..0a9481d 100644
--- a/packages/primitives/src/index.ts
+++ b/packages/primitives/src/index.ts
@@ -1,7 +1,9 @@
export * from './address.js';
export * from './block-header.js';
export * from './bytes.js';
+export * from './encrypter.js';
export * from './ext-json.js';
+export * from './hasher.js';
export * from './hd-private-node.js';
export * from './hd-public-node.js';
export * from './mnemonic.js';
diff --git a/packages/stack/tests/utils/encryption.spec.ts b/packages/primitives/tests/encryption.spec.ts
similarity index 98%
rename from packages/stack/tests/utils/encryption.spec.ts
rename to packages/primitives/tests/encryption.spec.ts
index 71f79e8..f8360bb 100644
--- a/packages/stack/tests/utils/encryption.spec.ts
+++ b/packages/primitives/tests/encryption.spec.ts
@@ -1,6 +1,6 @@
import { describe, it, expect, beforeEach } from 'vitest';
-import { Encrypter } from '~/src/utils/encrypter';
+import { Encrypter } from '../src/encrypter';
import { binToUtf8, utf8ToBin } from '@bitauth/libauth';
describe('Encrypter', () => {
diff --git a/packages/stack/src/storage/base-store.ts b/packages/stack/src/storage/base-store.ts
index ca87ceb..b6d3400 100644
--- a/packages/stack/src/storage/base-store.ts
+++ b/packages/stack/src/storage/base-store.ts
@@ -1,5 +1,5 @@
-import { Encrypter, EventEmitter, InverseBloomFilter } from '../utils';
-
+import { EventEmitter, InverseBloomFilter } from '../utils';
+import { Encrypter } from '@xocash/primitives';
export type StorageOpts = {
syncInMemory?: boolean;
encryption?: Encrypter;
diff --git a/packages/stack/src/storage/store-indexeddb.ts b/packages/stack/src/storage/store-indexeddb.ts
index e21401b..f4444f6 100644
--- a/packages/stack/src/storage/store-indexeddb.ts
+++ b/packages/stack/src/storage/store-indexeddb.ts
@@ -1,7 +1,7 @@
import { BaseStorage, BaseStore, StorageOpts } from './base-store.js';
import { StoreInMemorySynced } from './store-inmemory-synced.js';
-import { Encrypter } from '../utils';
+import { Encrypter } from '@xocash/primitives';
// TODO: Only use pack/unpack on encrypted content.
// Unsure why you were doing it on non-encrypted content (as it's not needed for IDB).
diff --git a/packages/stack/src/storage/store-remote-http.ts b/packages/stack/src/storage/store-remote-http.ts
index 0f0e461..211a30d 100644
--- a/packages/stack/src/storage/store-remote-http.ts
+++ b/packages/stack/src/storage/store-remote-http.ts
@@ -1,7 +1,8 @@
import { BaseStore } from './base-store.js';
-import { Encrypter, SSEClient } from '../utils';
+import { SSEClient } from '../utils';
import {
Bytes,
+ Encrypter,
PrivateKey,
PublicKey,
decodeExtendedJson,
diff --git a/packages/stack/src/utils/index.ts b/packages/stack/src/utils/index.ts
index b460fad..217fab5 100644
--- a/packages/stack/src/utils/index.ts
+++ b/packages/stack/src/utils/index.ts
@@ -1,7 +1,5 @@
-export * from './encrypter.js';
export * from './event-emitter.js';
export * from './ext-error.js';
-export * from './hasher.js';
export * from './inverse-bloom-filter.js';
export * from './memoizer.js';
export * from './misc.js';