@novasamatech/host-papp 0.6.2-0 → 0.6.3

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/dist/constants.js CHANGED
@@ -1,6 +1,3 @@
1
1
  export const SS_UNSTABLE_STAGE_ENDPOINTS = ['wss://pop-testnet.parity-lab.parity.io:443/9910'];
2
- export const SS_STABLE_STAGE_ENDPOINTS = [
3
- 'wss://pop3-testnet.parity-lab.parity.io:443/7911',
4
- 'wss://pop3-testnet.parity-lab.parity.io:443/7912',
5
- ];
2
+ export const SS_STABLE_STAGE_ENDPOINTS = ['wss://pop3-testnet.parity-lab.parity.io/people'];
6
3
  export const SS_PREVIEW_STAGE_ENDPOINTS = ['wss://previewnet.substrate.dev/people'];
@@ -61,19 +61,18 @@ export function createAuth({ metadata, statementStore, ssoSessionRepository, use
61
61
  }
62
62
  }
63
63
  });
64
- const secretesSaved = pappResponse.andThen(({ id }) => {
65
- return userSecretRepository.write(id, {
64
+ const sessionWithSecretsPayload = pappResponse.map(session => ({
65
+ session,
66
+ secretsPayload: {
67
+ id: session.id,
66
68
  ssSecret: account.secret,
67
69
  encrSecret: encrKeys.secret,
68
70
  entropy: account.entropy,
69
- });
70
- });
71
- // secrets and sso session should be chained, or it can produce an incorrect state
72
- const userCreated = secretesSaved.andThen(() => pappResponse.andThen(ssoSessionRepository.add));
73
- const sessionReceived = ResultAsync.combine([userCreated, secretesSaved]).map(([session]) => session);
74
- return sessionReceived
75
- .andTee(session => {
76
- pairingStatus.write(session ? { step: 'finished', session } : { step: 'none' });
71
+ },
72
+ }));
73
+ return sessionWithSecretsPayload
74
+ .andTee(({ session }) => {
75
+ pairingStatus.write({ step: 'finished', session });
77
76
  })
78
77
  .orTee(e => {
79
78
  if (!(e instanceof AbortError)) {
@@ -92,7 +91,18 @@ export function createAuth({ metadata, statementStore, ssoSessionRepository, use
92
91
  abort = new AbortController();
93
92
  const account = deriveSr25519Account(generateMnemonic(), '//wallet//sso');
94
93
  authResult = ResultAsync.combine([handshake(account, abort.signal), attestAccount(account, abort.signal)])
95
- .map(([session]) => session)
94
+ .andThen(([handshakeResult]) => {
95
+ // Save secrets and sso session only after attestation has finished
96
+ const { session, secretsPayload } = handshakeResult;
97
+ return userSecretRepository
98
+ .write(secretsPayload.id, {
99
+ ssSecret: secretsPayload.ssSecret,
100
+ encrSecret: secretsPayload.encrSecret,
101
+ entropy: secretsPayload.entropy,
102
+ })
103
+ .andThen(() => ssoSessionRepository.add(session))
104
+ .map(() => session);
105
+ })
96
106
  .orElse(e => (e instanceof AbortError ? ok(null) : err(e)))
97
107
  .andTee(() => {
98
108
  abort = null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-papp",
3
3
  "type": "module",
4
- "version": "0.6.2-0",
4
+ "version": "0.6.3",
5
5
  "description": "Polkadot app integration",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -28,10 +28,10 @@
28
28
  "@noble/ciphers": "2.1.1",
29
29
  "@noble/curves": "2.0.1",
30
30
  "@noble/hashes": "2.0.1",
31
- "@novasamatech/host-api": "0.6.2-0",
32
- "@novasamatech/scale": "0.6.2-0",
33
- "@novasamatech/statement-store": "0.6.2-0",
34
- "@novasamatech/storage-adapter": "0.6.2-0",
31
+ "@novasamatech/host-api": "0.6.3",
32
+ "@novasamatech/scale": "0.6.3",
33
+ "@novasamatech/statement-store": "0.6.3",
34
+ "@novasamatech/storage-adapter": "0.6.3",
35
35
  "@polkadot-api/utils": "0.2.0",
36
36
  "@polkadot-api/substrate-bindings": "^0.17.0",
37
37
  "@polkadot-labs/hdkd-helpers": "^0.0.27",