@novasamatech/host-container 0.6.12 → 0.6.13

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/README.md CHANGED
@@ -369,10 +369,16 @@ const chains = new Map([
369
369
  ['0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe', 'wss://kusama-rpc.polkadot.io'],
370
370
  ]);
371
371
 
372
- container.handleChainConnection((genesisHash) => {
373
- const endpoint = chains.get(genesisHash);
374
- if (!endpoint) return null;
375
- return getWsProvider(endpoint);
372
+ container.handleChainConnection({
373
+ factory(genesisHash) {
374
+ const endpoint = chains.get(genesisHash);
375
+ if (!endpoint) return null;
376
+ return getWsProvider(endpoint);
377
+ },
378
+ async submitPermission(transaction) {
379
+ if (hasPermission(transaction)) return true;
380
+ return false;
381
+ }
376
382
  });
377
383
  ```
378
384
 
@@ -505,7 +505,7 @@ export function createContainer(provider) {
505
505
  });
506
506
  },
507
507
  // chain interaction
508
- handleChainConnection(factory) {
508
+ handleChainConnection({ factory, submitPermission }) {
509
509
  init();
510
510
  const manager = createChainConnectionManager(factory);
511
511
  const cleanups = [];
@@ -740,11 +740,15 @@ export function createContainer(provider) {
740
740
  return enumValue('v1', resultErr(new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR })));
741
741
  }
742
742
  const { genesisHash, transaction } = message.value;
743
- const entry = manager.getOrCreateChain(genesisHash);
744
- if (!entry) {
745
- return enumValue('v1', resultErr(new GenericError({ reason: 'Chain not supported' })));
746
- }
747
743
  try {
744
+ const permissionGranted = await submitPermission(transaction);
745
+ if (!permissionGranted) {
746
+ return enumValue('v1', resultErr(new GenericError({ reason: 'Permission denied' })));
747
+ }
748
+ const entry = manager.getOrCreateChain(genesisHash);
749
+ if (!entry) {
750
+ return enumValue('v1', resultErr(new GenericError({ reason: 'Chain not supported' })));
751
+ }
748
752
  const result = await manager.sendRequest(genesisHash, 'transaction_v1_broadcast', [transaction]);
749
753
  manager.releaseChain(genesisHash);
750
754
  return enumValue('v1', resultOk(result ?? null));
package/dist/types.d.ts CHANGED
@@ -83,7 +83,10 @@ export type Container = {
83
83
  handleStatementStoreSubmit: InferHandler<'v1', HostApiProtocol['remote_statement_store_submit']>;
84
84
  handlePreimageLookupSubscribe: InferHandler<'v1', HostApiProtocol['remote_preimage_lookup_subscribe']>;
85
85
  handlePreimageSubmit: InferHandler<'v1', HostApiProtocol['remote_preimage_submit']>;
86
- handleChainConnection: (factory: (genesisHash: HexString) => JsonRpcProvider | null) => VoidFunction;
86
+ handleChainConnection: (params: {
87
+ factory: (genesisHash: HexString) => JsonRpcProvider | null;
88
+ submitPermission: (transaction: HexString) => Promise<boolean> | boolean;
89
+ }) => VoidFunction;
87
90
  isReady(): Promise<boolean>;
88
91
  dispose(): void;
89
92
  subscribeProductConnectionStatus(callback: (connectionStatus: ConnectionStatus) => void): VoidFunction;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-container",
3
3
  "type": "module",
4
- "version": "0.6.12",
4
+ "version": "0.6.13",
5
5
  "description": "Host container for hosting and managing products within the Polkadot ecosystem.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@polkadot-api/utils": "^0.2.0",
29
29
  "@polkadot-api/json-rpc-provider": "^0.0.4",
30
- "@novasamatech/host-api": "0.6.12",
30
+ "@novasamatech/host-api": "0.6.13",
31
31
  "nanoid": "5.1.7"
32
32
  },
33
33
  "devDependencies": {