@novasamatech/host-papp 0.5.4 → 0.5.5
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.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/sso/auth/attestationService.d.ts +1 -0
- package/dist/sso/auth/attestationService.js +12 -3
- package/dist/sso/sessionManager/impl.d.ts +1 -1
- package/dist/sso/sessionManager/impl.js +4 -1
- package/package.json +6 -6
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SS_STABLE_STAGE_ENDPOINTS, SS_UNSTABLE_STAGE_ENDPOINTS } from './constants.js';
|
|
1
|
+
export { SS_PREVIEW_STAGE_ENDPOINTS, SS_STABLE_STAGE_ENDPOINTS, SS_UNSTABLE_STAGE_ENDPOINTS } from './constants.js';
|
|
2
2
|
export type { PappAdapter } from './papp.js';
|
|
3
3
|
export { createPappAdapter } from './papp.js';
|
|
4
4
|
export type { AttestationStatus, PairingStatus } from './sso/auth/types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { SS_STABLE_STAGE_ENDPOINTS, SS_UNSTABLE_STAGE_ENDPOINTS } from './constants.js';
|
|
1
|
+
export { SS_PREVIEW_STAGE_ENDPOINTS, SS_STABLE_STAGE_ENDPOINTS, SS_UNSTABLE_STAGE_ENDPOINTS } from './constants.js';
|
|
2
2
|
export { createPappAdapter } from './papp.js';
|
|
@@ -2,6 +2,7 @@ import type { LazyClient } from '@novasamatech/statement-store';
|
|
|
2
2
|
import type { ResultAsync } from 'neverthrow';
|
|
3
3
|
import type { DerivedSr25519Account } from '../../crypto.js';
|
|
4
4
|
export declare function createSudoAliceVerifier(): DerivedSr25519Account;
|
|
5
|
+
export declare function withRetry<T>(fn: () => Promise<T>, maxRetries?: number): Promise<T>;
|
|
5
6
|
export declare const createAttestationService: (lazyClient: LazyClient) => {
|
|
6
7
|
claimUsername(): string;
|
|
7
8
|
grantVerifierAllowance(verifier: DerivedSr25519Account): ResultAsync<void, Error>;
|
|
@@ -13,6 +13,14 @@ const accountId = AccountId();
|
|
|
13
13
|
export function createSudoAliceVerifier() {
|
|
14
14
|
return deriveSr25519Account('bottom drive obey lake curtain smoke basket hold race lonely fit walk', '//Alice');
|
|
15
15
|
}
|
|
16
|
+
export function withRetry(fn, maxRetries = 1) {
|
|
17
|
+
return fn().catch(error => {
|
|
18
|
+
if (maxRetries > 0) {
|
|
19
|
+
return withRetry(fn, maxRetries - 1);
|
|
20
|
+
}
|
|
21
|
+
throw error;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
16
24
|
export const createAttestationService = (lazyClient) => {
|
|
17
25
|
const service = {
|
|
18
26
|
claimUsername() {
|
|
@@ -35,7 +43,7 @@ export const createAttestationService = (lazyClient) => {
|
|
|
35
43
|
const sudoCall = api.tx.Sudo.sudo({
|
|
36
44
|
call: increaseAllowanceCall.decodedCall,
|
|
37
45
|
});
|
|
38
|
-
return sudoCall.signAndSubmit(createPeopleSigner(verifier)).then(() => undefined);
|
|
46
|
+
return withRetry(() => sudoCall.signAndSubmit(createPeopleSigner(verifier)).then(() => undefined));
|
|
39
47
|
}, toError);
|
|
40
48
|
return verifierAllowance.andThen(verifierAllowance => (verifierAllowance > 0 ? okAsync() : getAllowance()));
|
|
41
49
|
},
|
|
@@ -108,7 +116,7 @@ export const createAttestationService = (lazyClient) => {
|
|
|
108
116
|
reserved_username: undefined,
|
|
109
117
|
},
|
|
110
118
|
});
|
|
111
|
-
|
|
119
|
+
const submitAttestation = () => new Promise((resolve, reject) => {
|
|
112
120
|
const subscription = attestCall.signSubmitAndWatch(createPeopleSigner(verifier)).subscribe({
|
|
113
121
|
next(event) {
|
|
114
122
|
if (event.type === 'finalized') {
|
|
@@ -131,7 +139,8 @@ export const createAttestationService = (lazyClient) => {
|
|
|
131
139
|
},
|
|
132
140
|
error: reject,
|
|
133
141
|
});
|
|
134
|
-
})
|
|
142
|
+
});
|
|
143
|
+
return fromPromise(withRetry(submitAttestation), toError).map(() => undefined);
|
|
135
144
|
})
|
|
136
145
|
.andTee(() => console.log(`Attestation for ${accountId.dec(candidate.publicKey)} successfully passed.`));
|
|
137
146
|
},
|
|
@@ -16,7 +16,7 @@ export declare function createSsoSessionManager({ ssoSessionRepository, userSecr
|
|
|
16
16
|
read: () => UserSession[];
|
|
17
17
|
subscribe: (callback: Callback<UserSession[]>) => () => void;
|
|
18
18
|
};
|
|
19
|
-
disconnect(userSession: StoredUserSession): import("neverthrow").ResultAsync<
|
|
19
|
+
disconnect(userSession: StoredUserSession): import("neverthrow").ResultAsync<void, Error>;
|
|
20
20
|
dispose(): void;
|
|
21
21
|
};
|
|
22
22
|
export {};
|
|
@@ -49,7 +49,10 @@ export function createSsoSessionManager({ ssoSessionRepository, userSecretReposi
|
|
|
49
49
|
},
|
|
50
50
|
disconnect(userSession) {
|
|
51
51
|
const session = createSession(userSession, statementStore, storage, userSecretRepository);
|
|
52
|
-
return session
|
|
52
|
+
return session
|
|
53
|
+
.sendDisconnectMessage()
|
|
54
|
+
.andThen(() => disconnect(userSession))
|
|
55
|
+
.andThen(() => userSecretRepository.clear(userSession.id));
|
|
53
56
|
},
|
|
54
57
|
dispose() {
|
|
55
58
|
for (const session of Object.values(localSessions.read())) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-papp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.5",
|
|
5
5
|
"description": "Polkadot app integration",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/Polkadot-Community-Foundation/triangle-js-sdks.git"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
12
|
"polkadot"
|
|
@@ -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.5.
|
|
32
|
-
"@novasamatech/scale": "0.5.
|
|
33
|
-
"@novasamatech/statement-store": "0.5.
|
|
34
|
-
"@novasamatech/storage-adapter": "0.5.
|
|
31
|
+
"@novasamatech/host-api": "0.5.5",
|
|
32
|
+
"@novasamatech/scale": "0.5.5",
|
|
33
|
+
"@novasamatech/statement-store": "0.5.5",
|
|
34
|
+
"@novasamatech/storage-adapter": "0.5.5",
|
|
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",
|