@totemsdk/edge 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,29 +1,29 @@
1
1
  {
2
2
  "name": "@totemsdk/edge",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Unified developer-facing runtime for Totem Edge — composes identity, manifest, wallet/payment/proof/lookup/policy capabilities via injected ports",
5
- "type": "module",
6
5
  "main": "dist/index.js",
7
6
  "types": "dist/index.d.ts",
8
7
  "exports": {
9
8
  ".": {
10
9
  "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
11
  "import": "./dist/index.js"
12
12
  }
13
13
  },
14
14
  "files": [
15
15
  "dist",
16
- "src",
17
- "README.md"
16
+ "README.md",
17
+ "LICENSE"
18
18
  ],
19
19
  "dependencies": {
20
20
  "@totemsdk/core": "1.0.9",
21
- "@totemsdk/manifest": "0.1.0",
22
- "@totemsdk/identity": "0.1.0",
23
- "@totemsdk/agent-policy": "0.1.2"
21
+ "@totemsdk/manifest": "0.1.1",
22
+ "@totemsdk/identity": "0.1.1",
23
+ "@totemsdk/agent-policy": "0.1.3"
24
24
  },
25
25
  "peerDependencies": {
26
- "@noble/hashes": ">=1.3.0 <2.0.0",
26
+ "@noble/hashes": ">=1.3.0",
27
27
  "@totemsdk/connect": "2.0.3"
28
28
  },
29
29
  "peerDependenciesMeta": {
@@ -35,7 +35,7 @@
35
35
  }
36
36
  },
37
37
  "devDependencies": {
38
- "@noble/hashes": "^1.3.0",
38
+ "@noble/hashes": "^2.2.0",
39
39
  "@types/jest": "^29.0.0",
40
40
  "@types/node": "^20.0.0",
41
41
  "jest": "^29.0.0",
@@ -50,6 +50,26 @@
50
50
  "access": "public"
51
51
  },
52
52
  "license": "MIT",
53
+ "author": "Totem SDK",
54
+ "homepage": "https://totemsdk.com",
55
+ "bugs": {
56
+ "url": "https://github.com/MrGheek/axia-totem/issues"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "git+https://github.com/MrGheek/axia-totem.git",
61
+ "directory": "packages/totem-sdk/packages/edge"
62
+ },
63
+ "keywords": [
64
+ "totem",
65
+ "totemsdk",
66
+ "minima",
67
+ "blockchain",
68
+ "quantum-resistant",
69
+ "wots",
70
+ "kissvm",
71
+ "utxo"
72
+ ],
53
73
  "scripts": {
54
74
  "build": "tsc",
55
75
  "clean": "rm -rf dist",
@@ -1,370 +0,0 @@
1
- /**
2
- * @totemsdk/edge — test suite
3
- */
4
-
5
- import {
6
- EDGE_VERSION,
7
- EdgeCapabilityError,
8
- createCapabilitySet,
9
- hasCapability,
10
- assertCapability,
11
- edgeCapabilitiesFromTotemCapabilities,
12
- createEdgeRuntime,
13
- createEdgeDevice,
14
- createEdgeReceipt,
15
- verifyEdgeReceipt,
16
- createEdgeServiceManifest,
17
- bindEdgeServiceIdentity,
18
- } from '../index';
19
- import type {
20
- EdgeCapability,
21
- EdgeCapabilitySet,
22
- EdgeRuntimePorts,
23
- } from '../index';
24
- import type { TotemCapabilities } from '@totemsdk/connect';
25
- import { createIdentityDocument } from '@totemsdk/identity';
26
- import type { IdentityGraph } from '@totemsdk/identity';
27
- import { wotsKeypairFromSeed, wotsAddressFromKeypair } from '@totemsdk/core';
28
-
29
- function deriveAddress(seed: Uint8Array, keyIndex: number): string {
30
- const kp = wotsKeypairFromSeed(seed, keyIndex);
31
- return wotsAddressFromKeypair(kp);
32
- }
33
-
34
- // ─── Capability set CRUD ──────────────────────────────────────────────────────
35
-
36
- describe('createCapabilitySet', () => {
37
- it('creates a capability set from an array', () => {
38
- const caps: EdgeCapability[] = ['wallet:self-custody', 'omnia:channels'];
39
- const set = createCapabilitySet(caps);
40
- expect(set.size).toBe(2);
41
- expect(set.has('wallet:self-custody')).toBe(true);
42
- expect(set.has('omnia:channels')).toBe(true);
43
- });
44
-
45
- it('hasCapability returns true/false correctly', () => {
46
- const set = createCapabilitySet(['wallet:self-custody']);
47
- expect(hasCapability(set, 'wallet:self-custody')).toBe(true);
48
- expect(hasCapability(set, 'omnia:channels')).toBe(false);
49
- });
50
- });
51
-
52
- // ─── assertCapability typed error ─────────────────────────────────────────────
53
-
54
- describe('assertCapability', () => {
55
- it('does not throw when capability is present', () => {
56
- const set = createCapabilitySet(['wallet:self-custody']);
57
- expect(() => assertCapability(set, 'wallet:self-custody')).not.toThrow();
58
- });
59
-
60
- it('throws EdgeCapabilityError when capability is missing', () => {
61
- const set = createCapabilitySet([]);
62
- let caught: unknown;
63
- try {
64
- assertCapability(set, 'omnia:channels');
65
- } catch (e) {
66
- caught = e;
67
- }
68
- expect(caught).toBeInstanceOf(EdgeCapabilityError);
69
- const err = caught as EdgeCapabilityError;
70
- expect(err.capability).toBe('omnia:channels');
71
- expect(err.code).toBe('EDGE_CAPABILITY_MISSING');
72
- });
73
- });
74
-
75
- // ─── edgeCapabilitiesFromTotemCapabilities ────────────────────────────────────
76
-
77
- describe('edgeCapabilitiesFromTotemCapabilities', () => {
78
- const representativeFixture: TotemCapabilities = {
79
- version: '4.1.0',
80
- wallet: {
81
- selfCustody: true,
82
- wotsTreeKey: true,
83
- rootIdentity: true,
84
- treeKeyDepth: 3,
85
- maxAddresses: 64,
86
- seedExport: false,
87
- custodyType: 'self',
88
- },
89
- account: {
90
- multiAddress: true,
91
- accountSwitcher: true,
92
- },
93
- chain: {
94
- hostedProvider: true,
95
- pureMinimaRpc: false,
96
- lookupNode: true,
97
- localProofVerify: true,
98
- pearRuntime: false,
99
- hyperswarm: true,
100
- },
101
- txpow: {
102
- localMining: false,
103
- progressEvents: true,
104
- },
105
- omnia: {
106
- channels: true,
107
- routing: true,
108
- multiHop: false,
109
- crossTokenSwap: false,
110
- factory: false,
111
- virtualChannels: false,
112
- splicing: false,
113
- hyperswarm: true,
114
- },
115
- statechain: {
116
- supported: false,
117
- blindSE: false,
118
- },
119
- scripting: {
120
- kissvm: true,
121
- },
122
- qvac: {
123
- paymentIntents: true,
124
- explanations: false,
125
- },
126
- };
127
-
128
- it('maps wallet.selfCustody to wallet:self-custody', () => {
129
- const set = edgeCapabilitiesFromTotemCapabilities(representativeFixture);
130
- expect(set.has('wallet:self-custody')).toBe(true);
131
- });
132
-
133
- it('maps omnia.channels to omnia:channels', () => {
134
- const set = edgeCapabilitiesFromTotemCapabilities(representativeFixture);
135
- expect(set.has('omnia:channels')).toBe(true);
136
- });
137
-
138
- it('does not include capabilities that are false', () => {
139
- const set = edgeCapabilitiesFromTotemCapabilities(representativeFixture);
140
- expect(set.has('txpow:local-mining')).toBe(false);
141
- expect(set.has('statechain:supported')).toBe(false);
142
- expect(set.has('wallet:seed-export')).toBe(false);
143
- });
144
-
145
- it('maps scripting.kissvm to scripting:kissvm', () => {
146
- const set = edgeCapabilitiesFromTotemCapabilities(representativeFixture);
147
- expect(set.has('scripting:kissvm')).toBe(true);
148
- });
149
-
150
- it('round-trips representative fixture and contains expected EdgeCapability values', () => {
151
- const set = edgeCapabilitiesFromTotemCapabilities(representativeFixture);
152
- const expected: EdgeCapability[] = [
153
- 'wallet:self-custody',
154
- 'wallet:wots-tree-key',
155
- 'wallet:root-identity',
156
- 'account:multi-address',
157
- 'account:switcher',
158
- 'chain:hosted-provider',
159
- 'chain:lookup-node',
160
- 'chain:local-proof-verify',
161
- 'chain:hyperswarm',
162
- 'txpow:progress-events',
163
- 'omnia:channels',
164
- 'omnia:routing',
165
- 'omnia:hyperswarm',
166
- 'scripting:kissvm',
167
- 'qvac:payment-intents',
168
- ];
169
- for (const cap of expected) {
170
- expect(set.has(cap)).toBe(true);
171
- }
172
- });
173
- });
174
-
175
- // ─── Runtime with no/mocked ports ────────────────────────────────────────────
176
-
177
- describe('createEdgeRuntime', () => {
178
- it('creates a runtime with no ports', () => {
179
- const caps = createCapabilitySet(['wallet:self-custody']);
180
- const runtime = createEdgeRuntime({ deviceId: 'dev-1', capabilities: caps, ports: {} });
181
- expect(runtime.version).toBe(EDGE_VERSION);
182
- expect(runtime.deviceId).toBe('dev-1');
183
- expect(runtime.hasCapability('wallet:self-custody')).toBe(true);
184
- expect(runtime.hasCapability('omnia:channels')).toBe(false);
185
- });
186
-
187
- it('creates a runtime with mocked payment port', () => {
188
- const mockedPayment = {
189
- async pay() {
190
- return { ok: true, data: { txpowId: 'tx-abc' } };
191
- },
192
- };
193
- const ports: EdgeRuntimePorts = { payment: mockedPayment };
194
- const caps = createCapabilitySet(['payment:send']);
195
- const runtime = createEdgeRuntime({ deviceId: 'dev-2', capabilities: caps, ports });
196
- expect(runtime.ports.payment).toBe(mockedPayment);
197
- });
198
-
199
- it('assertCapability throws for missing capability', () => {
200
- const caps = createCapabilitySet([]);
201
- const runtime = createEdgeRuntime({ deviceId: 'dev-3', capabilities: caps, ports: {} });
202
- expect(() => runtime.assertCapability('omnia:channels')).toThrow(EdgeCapabilityError);
203
- });
204
- });
205
-
206
- // ─── Device binding ───────────────────────────────────────────────────────────
207
-
208
- describe('createEdgeDevice', () => {
209
- it('creates a device with unique ID', () => {
210
- const d1 = createEdgeDevice({ kind: 'sensor' });
211
- const d2 = createEdgeDevice({ kind: 'sensor' });
212
- expect(d1.deviceId).toMatch(/^edge:device:/);
213
- // IDs differ due to different timestamps
214
- expect(d1.deviceId).not.toBe(d2.deviceId);
215
- });
216
-
217
- it('stores kind and metadata', () => {
218
- const d = createEdgeDevice({
219
- kind: 'robot',
220
- address: 'MxROBOT',
221
- identityId: 'totem:id:robot:abc',
222
- metadata: { model: 'R2D2' },
223
- });
224
- expect(d.kind).toBe('robot');
225
- expect(d.address).toBe('MxROBOT');
226
- expect(d.identityId).toBe('totem:id:robot:abc');
227
- expect(d.metadata?.model).toBe('R2D2');
228
- });
229
- });
230
-
231
- // ─── Receipt ID stability ─────────────────────────────────────────────────────
232
-
233
- describe('createEdgeReceipt', () => {
234
- it('creates a receipt with stable ID for same inputs', () => {
235
- const r1 = createEdgeReceipt({ kind: 'payment', payload: { amount: '10' }, issuedAt: 1000 });
236
- const r2 = createEdgeReceipt({ kind: 'payment', payload: { amount: '10' }, issuedAt: 1000 });
237
- expect(r1.receiptId).toBe(r2.receiptId);
238
- });
239
-
240
- it('different payload produces different receipt ID', () => {
241
- const r1 = createEdgeReceipt({ kind: 'payment', payload: { amount: '10' }, issuedAt: 1000 });
242
- const r2 = createEdgeReceipt({ kind: 'payment', payload: { amount: '20' }, issuedAt: 1000 });
243
- expect(r1.receiptId).not.toBe(r2.receiptId);
244
- });
245
-
246
- it('includes relatedManifestId when provided', () => {
247
- const r = createEdgeReceipt({
248
- kind: 'manifest',
249
- payload: {},
250
- relatedManifestId: 'manifest-xyz',
251
- issuedAt: 1000,
252
- });
253
- expect(r.relatedManifestId).toBe('manifest-xyz');
254
- });
255
- });
256
-
257
- // ─── Unsigned receipt verify safety ──────────────────────────────────────────
258
-
259
- describe('verifyEdgeReceipt', () => {
260
- it('returns ok:true for valid receipt', () => {
261
- const r = createEdgeReceipt({ kind: 'payment', payload: { amount: '5' }, issuedAt: 2000 });
262
- const result = verifyEdgeReceipt(r);
263
- expect(result.ok).toBe(true);
264
- expect(result.data?.receipt.receiptId).toBe(r.receiptId);
265
- });
266
-
267
- it('returns ok:false for null', () => {
268
- const result = verifyEdgeReceipt(null);
269
- expect(result.ok).toBe(false);
270
- expect(result.errorCode).toBe('INVALID_RECEIPT');
271
- });
272
-
273
- it('returns ok:false for missing receiptId', () => {
274
- const result = verifyEdgeReceipt({ kind: 'x', issuedAt: 1, payload: {} });
275
- expect(result.ok).toBe(false);
276
- });
277
-
278
- it('never returns a bare boolean', () => {
279
- const result = verifyEdgeReceipt(null);
280
- expect(typeof result).toBe('object');
281
- expect(typeof result.ok).toBe('boolean');
282
- });
283
- });
284
-
285
- // ─── Service manifest creation ────────────────────────────────────────────────
286
-
287
- describe('createEdgeServiceManifest', () => {
288
- const SEED = new Uint8Array(32).fill(42);
289
-
290
- it('creates a signed EdgeServiceManifest', async () => {
291
- const signerAddr = deriveAddress(SEED, 0);
292
- const manifest = {
293
- type: 'edge-service' as const,
294
- serviceId: 'svc-test',
295
- name: 'Test Service',
296
- version: '1.0.0',
297
- operatorAddress: signerAddr,
298
- serviceType: 'sensor' as const,
299
- description: 'test',
300
- capabilities: [],
301
- tags: [],
302
- };
303
- const signed = await createEdgeServiceManifest(manifest, SEED, 0);
304
- expect(signed.manifest.type).toBe('edge-service');
305
- expect(typeof signed.signature).toBe('string');
306
- expect(typeof signed.authorAddress).toBe('string');
307
- }, 30000);
308
- });
309
-
310
- // ─── bindEdgeServiceIdentity ──────────────────────────────────────────────────
311
-
312
- describe('bindEdgeServiceIdentity', () => {
313
- const SEED = new Uint8Array(32).fill(42);
314
-
315
- it('binds service identity successfully', async () => {
316
- const signerAddr = deriveAddress(SEED, 0);
317
- const manifest = {
318
- type: 'edge-service' as const,
319
- serviceId: 'svc-bind-test',
320
- name: 'Bind Test',
321
- version: '1.0.0',
322
- operatorAddress: signerAddr,
323
- serviceType: 'sensor' as const,
324
- description: 'bind test',
325
- capabilities: [],
326
- tags: [],
327
- };
328
- const signed = await createEdgeServiceManifest(manifest, SEED, 0);
329
- const doc = createIdentityDocument({
330
- kind: 'service',
331
- rootAddress: signed.authorAddress,
332
- controllerAddress: signed.authorAddress,
333
- });
334
- const graph: IdentityGraph = { document: doc, claims: [] };
335
- const binding = await bindEdgeServiceIdentity(signed, graph);
336
- expect(binding.valid).toBe(true);
337
- expect(binding.signerAddress).toBe(signed.authorAddress);
338
- }, 30000);
339
- });
340
-
341
- // ─── Package root export check ────────────────────────────────────────────────
342
-
343
- describe('package root export', () => {
344
- it('exports EDGE_VERSION', () => {
345
- expect(EDGE_VERSION).toBe(1);
346
- });
347
-
348
- it('exports all required symbols', () => {
349
- const exports = require('../index');
350
- const required = [
351
- 'EDGE_VERSION',
352
- 'EdgeCapabilityError',
353
- 'createCapabilitySet',
354
- 'hasCapability',
355
- 'assertCapability',
356
- 'edgeCapabilitiesFromTotemCapabilities',
357
- 'createEdgeRuntime',
358
- 'createEdgeDevice',
359
- 'createEdgeReceipt',
360
- 'verifyEdgeReceipt',
361
- 'createEdgeProviderProfile',
362
- 'createEdgeServiceRegistration',
363
- 'createEdgeServiceManifest',
364
- 'bindEdgeServiceIdentity',
365
- ];
366
- for (const sym of required) {
367
- expect(exports[sym]).toBeDefined();
368
- }
369
- });
370
- });
package/src/canonical.ts DELETED
@@ -1,29 +0,0 @@
1
- /**
2
- * Plain hex encoder (no 0x prefix) for use in ID URIs and deterministic identifiers.
3
- * bytesToHex from @totemsdk/core adds a 0x prefix — use this for URI-safe hex IDs.
4
- */
5
- export function toHex(bytes: Uint8Array): string {
6
- return Array.from(bytes)
7
- .map((b) => b.toString(16).padStart(2, '0'))
8
- .join('');
9
- }
10
-
11
- /**
12
- * Local canonical JSON helper for @totemsdk/edge.
13
- *
14
- * Identical in behaviour to the one in @totemsdk/identity, but kept local
15
- * so both packages remain independently deployable. If a shared helper is
16
- * extracted to a low-level package in a future task it can replace both copies.
17
- */
18
- export function canonicalJson(value: unknown): string {
19
- if (value === null || typeof value !== 'object') {
20
- return JSON.stringify(value);
21
- }
22
- if (Array.isArray(value)) {
23
- return '[' + value.map(canonicalJson).join(',') + ']';
24
- }
25
- const obj = value as Record<string, unknown>;
26
- const keys = Object.keys(obj).sort();
27
- const pairs = keys.map((k) => `${JSON.stringify(k)}:${canonicalJson(obj[k])}`);
28
- return '{' + pairs.join(',') + '}';
29
- }
@@ -1,115 +0,0 @@
1
- /**
2
- * Edge capability model.
3
- *
4
- * EdgeCapability strings follow a domain:action pattern.
5
- * edgeCapabilitiesFromTotemCapabilities maps @totemsdk/connect's TotemCapabilities
6
- * to an EdgeCapabilitySet without any runtime import of @totemsdk/connect.
7
- */
8
-
9
- import type { TotemCapabilities } from '@totemsdk/connect';
10
- import { EdgeCapabilityError } from './errors.js';
11
-
12
- export type EdgeCapability =
13
- | 'wallet:self-custody'
14
- | 'wallet:wots-tree-key'
15
- | 'wallet:root-identity'
16
- | 'wallet:seed-export'
17
- | 'account:multi-address'
18
- | 'account:switcher'
19
- | 'chain:hosted-provider'
20
- | 'chain:pure-rpc'
21
- | 'chain:lookup-node'
22
- | 'chain:local-proof-verify'
23
- | 'chain:pear-runtime'
24
- | 'chain:hyperswarm'
25
- | 'txpow:local-mining'
26
- | 'txpow:progress-events'
27
- | 'omnia:channels'
28
- | 'omnia:routing'
29
- | 'omnia:multi-hop'
30
- | 'omnia:cross-token-swap'
31
- | 'omnia:factory'
32
- | 'omnia:virtual-channels'
33
- | 'omnia:splicing'
34
- | 'omnia:hyperswarm'
35
- | 'statechain:supported'
36
- | 'statechain:blind-se'
37
- | 'scripting:kissvm'
38
- | 'qvac:payment-intents'
39
- | 'qvac:explanations'
40
- | 'proof:create'
41
- | 'proof:verify'
42
- | 'lookup:watch'
43
- | 'identity:resolve'
44
- | 'manifest:sign'
45
- | 'manifest:verify'
46
- | 'payment:send'
47
- | 'policy:check';
48
-
49
- export type EdgeCapabilitySet = Set<EdgeCapability>;
50
-
51
- export function createCapabilitySet(caps: EdgeCapability[]): EdgeCapabilitySet {
52
- return new Set(caps);
53
- }
54
-
55
- export function hasCapability(set: EdgeCapabilitySet, cap: EdgeCapability): boolean {
56
- return set.has(cap);
57
- }
58
-
59
- export function assertCapability(set: EdgeCapabilitySet, cap: EdgeCapability): void {
60
- if (!set.has(cap)) {
61
- throw new EdgeCapabilityError(cap);
62
- }
63
- }
64
-
65
- /**
66
- * Maps boolean fields from @totemsdk/connect's TotemCapabilities to the
67
- * appropriate EdgeCapability strings.
68
- *
69
- * @totemsdk/connect is imported as a type-only import — no runtime import
70
- * is emitted, preserving independent deployability of @totemsdk/edge.
71
- */
72
- export function edgeCapabilitiesFromTotemCapabilities(
73
- caps: TotemCapabilities,
74
- ): EdgeCapabilitySet {
75
- const result: EdgeCapability[] = [];
76
-
77
- const { wallet, account, chain, txpow, omnia, statechain, scripting, qvac } = caps;
78
-
79
- if (wallet.selfCustody) result.push('wallet:self-custody');
80
- if (wallet.wotsTreeKey) result.push('wallet:wots-tree-key');
81
- if (wallet.rootIdentity) result.push('wallet:root-identity');
82
- if (wallet.seedExport) result.push('wallet:seed-export');
83
-
84
- if (account.multiAddress) result.push('account:multi-address');
85
- if (account.accountSwitcher) result.push('account:switcher');
86
-
87
- if (chain.hostedProvider) result.push('chain:hosted-provider');
88
- if (chain.pureMinimaRpc) result.push('chain:pure-rpc');
89
- if (chain.lookupNode) result.push('chain:lookup-node');
90
- if (chain.localProofVerify) result.push('chain:local-proof-verify');
91
- if (chain.pearRuntime) result.push('chain:pear-runtime');
92
- if (chain.hyperswarm) result.push('chain:hyperswarm');
93
-
94
- if (txpow.localMining) result.push('txpow:local-mining');
95
- if (txpow.progressEvents) result.push('txpow:progress-events');
96
-
97
- if (omnia.channels) result.push('omnia:channels');
98
- if (omnia.routing) result.push('omnia:routing');
99
- if (omnia.multiHop) result.push('omnia:multi-hop');
100
- if (omnia.crossTokenSwap) result.push('omnia:cross-token-swap');
101
- if (omnia.factory) result.push('omnia:factory');
102
- if (omnia.virtualChannels) result.push('omnia:virtual-channels');
103
- if (omnia.splicing) result.push('omnia:splicing');
104
- if (omnia.hyperswarm) result.push('omnia:hyperswarm');
105
-
106
- if (statechain.supported) result.push('statechain:supported');
107
- if (statechain.blindSE) result.push('statechain:blind-se');
108
-
109
- if (scripting.kissvm) result.push('scripting:kissvm');
110
-
111
- if (qvac.paymentIntents) result.push('qvac:payment-intents');
112
- if (qvac.explanations) result.push('qvac:explanations');
113
-
114
- return createCapabilitySet(result);
115
- }
package/src/constants.ts DELETED
@@ -1 +0,0 @@
1
- export const EDGE_VERSION = 1 as const;
package/src/device.ts DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * Edge device factory.
3
- */
4
-
5
- import { sha3_256 } from '@noble/hashes/sha3.js';
6
- import { toHex } from './canonical.js';
7
- import type { EdgeDevice, EdgeDeviceKind } from './types.js';
8
-
9
- export function createEdgeDevice(opts: {
10
- kind: EdgeDeviceKind;
11
- identityId?: string;
12
- address?: string;
13
- metadata?: Record<string, unknown>;
14
- }): EdgeDevice {
15
- const { kind, identityId, address, metadata } = opts;
16
-
17
- const ts = Date.now();
18
- const raw = `edge-device\0${kind}\0${identityId ?? ''}\0${address ?? ''}\0${ts}`;
19
- const hash = sha3_256(new TextEncoder().encode(raw));
20
- const deviceId = `edge:device:${toHex(hash)}`;
21
-
22
- return {
23
- deviceId,
24
- kind,
25
- ...(identityId !== undefined ? { identityId } : {}),
26
- ...(address !== undefined ? { address } : {}),
27
- ...(metadata !== undefined ? { metadata } : {}),
28
- createdAt: ts,
29
- };
30
- }
package/src/errors.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * Typed errors for @totemsdk/edge.
3
- */
4
-
5
- export class EdgeCapabilityError extends Error {
6
- readonly code: string;
7
- readonly capability: string;
8
-
9
- constructor(capability: string, message?: string) {
10
- super(message ?? `Capability not available: ${capability}`);
11
- this.name = 'EdgeCapabilityError';
12
- this.code = 'EDGE_CAPABILITY_MISSING';
13
- this.capability = capability;
14
- }
15
- }
package/src/index.ts DELETED
@@ -1,52 +0,0 @@
1
- /**
2
- * @module @totemsdk/edge
3
- *
4
- * Unified developer-facing runtime for Totem Edge.
5
- * Composes identity, manifest, wallet/payment/proof/lookup/policy capabilities
6
- * via injected ports. Adapter-neutral.
7
- */
8
-
9
- export { EDGE_VERSION } from './constants.js';
10
-
11
- export { EdgeCapabilityError } from './errors.js';
12
-
13
- export type {
14
- EdgeDeviceKind,
15
- EdgeOperationResult,
16
- EdgeDevice,
17
- EdgeRuntime,
18
- EdgeProviderProfile,
19
- EdgeServiceRegistration,
20
- EdgeReceipt,
21
- } from './types.js';
22
-
23
- export type {
24
- EdgePaymentPort,
25
- EdgeLiquidityPort,
26
- EdgeProofPort,
27
- EdgeLookupPort,
28
- EdgePolicyPort,
29
- EdgeIdentityPort,
30
- EdgeManifestPort,
31
- EdgeRuntimePorts,
32
- } from './ports.js';
33
-
34
- export type { EdgeCapability, EdgeCapabilitySet } from './capabilities.js';
35
- export {
36
- createCapabilitySet,
37
- hasCapability,
38
- assertCapability,
39
- edgeCapabilitiesFromTotemCapabilities,
40
- } from './capabilities.js';
41
-
42
- export { createEdgeRuntime } from './runtime.js';
43
- export { createEdgeDevice } from './device.js';
44
-
45
- export { createEdgeReceipt, verifyEdgeReceipt } from './receipts.js';
46
-
47
- export {
48
- createEdgeProviderProfile,
49
- createEdgeServiceRegistration,
50
- createEdgeServiceManifest,
51
- bindEdgeServiceIdentity,
52
- } from './provider.js';