@novasamatech/host-papp 0.7.6 → 0.7.7

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.
@@ -57,7 +57,7 @@ function createCachedIdentityRequester(storage, getKey) {
57
57
  if (emptyIdentities.length === 0) {
58
58
  return okAsync(existing);
59
59
  }
60
- return request(accounts)
60
+ return request(emptyIdentities)
61
61
  .andThen(writeCache)
62
62
  .map(fetched => ({
63
63
  ...existing,
@@ -159,18 +159,20 @@ function createPeopleSigner(verifier) {
159
159
  publicKey: baseSigner.publicKey,
160
160
  signBytes: baseSigner.signBytes,
161
161
  signTx: async (callData, signedExtensions, metadata, atBlockNumber, hasher) => {
162
- // Add People chain custom signed extensions
162
+ // polkadot-api auto-derives all signed extensions whose default state is encodable as
163
+ // a zero byte (Option::None, struct(Option<_>) = None, etc.). The People runtime's
164
+ // `pallet_verify_signature::VerifySignature` ({ Disabled, Signed }) extension uses
165
+ // identifier "VerifyMultiSignature" but has no built-in handler in polkadot-api, so it
166
+ // must be supplied manually. Value 0x00 = `Disabled` (passthrough — the standard
167
+ // extrinsic signature authenticates the call). Variant tag order was flipped in
168
+ // polkadot-sdk#11897 specifically so generic signers can encode the passthrough state
169
+ // as a single zero byte.
163
170
  const extensionsWithCustom = {
164
171
  ...signedExtensions,
165
172
  VerifyMultiSignature: {
166
173
  identifier: 'VerifyMultiSignature',
167
- value: new Uint8Array([1]), // 1u8 = Option::Some with empty data
168
- additionalSigned: new Uint8Array([]), // Empty additional data
169
- },
170
- AsPerson: {
171
- identifier: 'AsPerson',
172
- value: new Uint8Array([0]), // 0u8 = Option::None
173
- additionalSigned: new Uint8Array([]), // Empty additional data
174
+ value: new Uint8Array([0]),
175
+ additionalSigned: new Uint8Array([]),
174
176
  },
175
177
  };
176
178
  return baseSigner.signTx(callData, extensionsWithCustom, metadata, atBlockNumber, hasher);
@@ -5,6 +5,11 @@ import { createSsoStatementProver } from '../ssoSessionProver.js';
5
5
  import { createUserSession } from './userSession.js';
6
6
  export function createSsoSessionManager({ ssoSessionRepository, userSecretRepository, statementStore, storage, }) {
7
7
  const localSessions = createState({});
8
+ const sessionUnsubscribes = new Map();
9
+ const releaseSession = (id) => {
10
+ sessionUnsubscribes.get(id)?.();
11
+ sessionUnsubscribes.delete(id);
12
+ };
8
13
  const disconnect = (session) => {
9
14
  return ssoSessionRepository.filter(s => s.id !== session.id).map(() => undefined);
10
15
  };
@@ -13,12 +18,12 @@ export function createSsoSessionManager({ ssoSessionRepository, userSecretReposi
13
18
  const toRemove = new Set(Object.keys(activeSessions));
14
19
  const toAdd = new Set();
15
20
  for (const userSession of userSessions) {
21
+ toRemove.delete(userSession.id);
16
22
  if (userSession.id in activeSessions)
17
23
  continue;
18
24
  const session = createSession(userSession, statementStore, storage, userSecretRepository);
19
- toRemove.delete(userSession.id);
20
25
  toAdd.add(session);
21
- session.subscribe(message => {
26
+ const unsubscribe = session.subscribe(message => {
22
27
  switch (message.data.tag) {
23
28
  case 'v1': {
24
29
  switch (message.data.value.tag) {
@@ -29,8 +34,13 @@ export function createSsoSessionManager({ ssoSessionRepository, userSecretReposi
29
34
  }
30
35
  return okAsync(false);
31
36
  });
37
+ sessionUnsubscribes.set(session.id, unsubscribe);
32
38
  }
33
39
  if (toRemove.size > 0) {
40
+ for (const id of toRemove) {
41
+ releaseSession(id);
42
+ activeSessions[id]?.dispose();
43
+ }
34
44
  localSessions.write(prev => {
35
45
  return Object.fromEntries(Object.entries(prev).filter(([id]) => !toRemove.has(id)));
36
46
  });
@@ -56,6 +66,7 @@ export function createSsoSessionManager({ ssoSessionRepository, userSecretReposi
56
66
  },
57
67
  dispose() {
58
68
  for (const session of Object.values(localSessions.read())) {
69
+ releaseSession(session.id);
59
70
  session.dispose();
60
71
  }
61
72
  },
@@ -141,7 +141,9 @@ export function createUserSession({ userSession, statementStore, encryption, sto
141
141
  },
142
142
  subscribe(callback) {
143
143
  return session.subscribe(RemoteMessageCodec, messages => {
144
- processedMessages.read().andThen(processed => {
144
+ processedMessages
145
+ .read()
146
+ .andThen(processed => {
145
147
  const results = messages.map(message => {
146
148
  if (message.type === 'request' && message.payload.status === 'parsed') {
147
149
  const payload = message.payload;
@@ -165,6 +167,9 @@ export function createUserSession({ userSession, statementStore, encryption, sto
165
167
  }
166
168
  return okAsync();
167
169
  });
170
+ })
171
+ .orTee(error => {
172
+ console.error('Error while updating processed sso messages:', error);
168
173
  });
169
174
  });
170
175
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-papp",
3
3
  "type": "module",
4
- "version": "0.7.6",
4
+ "version": "0.7.7",
5
5
  "description": "Polkadot app integration",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -29,10 +29,10 @@
29
29
  "@noble/ciphers": "2.2.0",
30
30
  "@noble/curves": "2.2.0",
31
31
  "@noble/hashes": "2.2.0",
32
- "@novasamatech/host-api": "0.7.6",
33
- "@novasamatech/scale": "0.7.6",
34
- "@novasamatech/statement-store": "0.7.6",
35
- "@novasamatech/storage-adapter": "0.7.6",
32
+ "@novasamatech/host-api": "0.7.7",
33
+ "@novasamatech/scale": "0.7.7",
34
+ "@novasamatech/statement-store": "0.7.7",
35
+ "@novasamatech/storage-adapter": "0.7.7",
36
36
  "@polkadot-labs/hdkd-helpers": "^0.0.30",
37
37
  "nanoevents": "9.1.0",
38
38
  "nanoid": "5.1.9",