@novasamatech/host-papp 0.7.9-2 → 0.7.9-4
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/index.d.ts +1 -1
- package/dist/papp.js +0 -1
- package/dist/sso/auth/impl.d.ts +8 -33
- package/dist/sso/auth/impl.js +3 -28
- package/dist/sso/auth/types.d.ts +3 -13
- package/package.json +6 -7
- package/dist/helpers/callbackRaceResolver.d.ts +0 -1
- package/dist/helpers/callbackRaceResolver.js +0 -17
- package/dist/sso/sessionManager/scale/hex.d.ts +0 -1
- package/dist/sso/sessionManager/scale/hex.js +0 -3
- package/dist/sso/sessionManager/scale/signPayloadRequest.d.ts +0 -20
- package/dist/sso/sessionManager/scale/signPayloadRequest.js +0 -20
- package/dist/sso/sessionManager/scale/signPayloadResponse.d.ts +0 -14
- package/dist/sso/sessionManager/scale/signPayloadResponse.js +0 -10
- package/dist/sso/sessionManager/types.d.ts +0 -6
- package/dist/sso/sessionManager/types.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { SS_PASEO_STABLE_STAGE_ENDPOINTS, SS_PREVIEW_STAGE_ENDPOINTS, SS_STABLE_
|
|
|
2
2
|
export type { PappAdapter } from './papp.js';
|
|
3
3
|
export { createPappAdapter } from './papp.js';
|
|
4
4
|
export type { HostMetadata } from './sso/auth/impl.js';
|
|
5
|
-
export type {
|
|
5
|
+
export type { PairingStatus } from './sso/auth/types.js';
|
|
6
6
|
export type { UserSession } from './sso/sessionManager/userSession.js';
|
|
7
7
|
export type { StoredUserSession } from './sso/userSessionRepository.js';
|
|
8
8
|
export type { Identity } from './identity/types.js';
|
package/dist/papp.js
CHANGED
|
@@ -23,7 +23,6 @@ export function createPappAdapter({ appId, metadata, hostMetadata, adapters }) {
|
|
|
23
23
|
statementStore,
|
|
24
24
|
ssoSessionRepository,
|
|
25
25
|
userSecretRepository,
|
|
26
|
-
lazyClient,
|
|
27
26
|
}),
|
|
28
27
|
sessions: createSsoSessionManager({ storage, statementStore, ssoSessionRepository, userSecretRepository }),
|
|
29
28
|
secrets: userSecretRepository,
|
package/dist/sso/auth/impl.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StatementStoreAdapter } from '@novasamatech/statement-store';
|
|
2
2
|
import { ResultAsync } from 'neverthrow';
|
|
3
3
|
import type { UserSecretRepository } from '../userSecretRepository.js';
|
|
4
4
|
import type { StoredUserSession, UserSessionRepository } from '../userSessionRepository.js';
|
|
@@ -14,19 +14,19 @@ type Params = {
|
|
|
14
14
|
statementStore: StatementStoreAdapter;
|
|
15
15
|
ssoSessionRepository: UserSessionRepository;
|
|
16
16
|
userSecretRepository: UserSecretRepository;
|
|
17
|
-
lazyClient: LazyClient;
|
|
18
17
|
};
|
|
19
|
-
export declare function createAuth({ metadata, hostMetadata, statementStore, ssoSessionRepository, userSecretRepository,
|
|
18
|
+
export declare function createAuth({ metadata, hostMetadata, statementStore, ssoSessionRepository, userSecretRepository, }: Params): {
|
|
20
19
|
pairingStatus: {
|
|
21
20
|
read: () => {
|
|
22
21
|
step: "none";
|
|
23
22
|
} | {
|
|
24
23
|
step: "initial";
|
|
25
|
-
} | {
|
|
26
|
-
step: "attestation";
|
|
27
24
|
} | {
|
|
28
25
|
step: "pairing";
|
|
29
26
|
payload: string;
|
|
27
|
+
} | {
|
|
28
|
+
step: "pending";
|
|
29
|
+
stage: string;
|
|
30
30
|
} | {
|
|
31
31
|
step: "pairingError";
|
|
32
32
|
message: string;
|
|
@@ -38,11 +38,12 @@ export declare function createAuth({ metadata, hostMetadata, statementStore, sso
|
|
|
38
38
|
step: "none";
|
|
39
39
|
} | {
|
|
40
40
|
step: "initial";
|
|
41
|
-
} | {
|
|
42
|
-
step: "attestation";
|
|
43
41
|
} | {
|
|
44
42
|
step: "pairing";
|
|
45
43
|
payload: string;
|
|
44
|
+
} | {
|
|
45
|
+
step: "pending";
|
|
46
|
+
stage: string;
|
|
46
47
|
} | {
|
|
47
48
|
step: "pairingError";
|
|
48
49
|
message: string;
|
|
@@ -53,32 +54,6 @@ export declare function createAuth({ metadata, hostMetadata, statementStore, sso
|
|
|
53
54
|
onFirstSubscribe: (callback: VoidFunction) => import("nanoevents").Unsubscribe;
|
|
54
55
|
onLastUnsubscribe: (callback: VoidFunction) => import("nanoevents").Unsubscribe;
|
|
55
56
|
};
|
|
56
|
-
attestationStatus: {
|
|
57
|
-
read: () => {
|
|
58
|
-
step: "none";
|
|
59
|
-
} | {
|
|
60
|
-
step: "attestation";
|
|
61
|
-
username: string;
|
|
62
|
-
} | {
|
|
63
|
-
step: "attestationError";
|
|
64
|
-
message: string;
|
|
65
|
-
} | {
|
|
66
|
-
step: "finished";
|
|
67
|
-
};
|
|
68
|
-
subscribe: (fn: (value: {
|
|
69
|
-
step: "none";
|
|
70
|
-
} | {
|
|
71
|
-
step: "attestation";
|
|
72
|
-
username: string;
|
|
73
|
-
} | {
|
|
74
|
-
step: "attestationError";
|
|
75
|
-
message: string;
|
|
76
|
-
} | {
|
|
77
|
-
step: "finished";
|
|
78
|
-
}) => void) => () => void;
|
|
79
|
-
onFirstSubscribe: (callback: VoidFunction) => import("nanoevents").Unsubscribe;
|
|
80
|
-
onLastUnsubscribe: (callback: VoidFunction) => import("nanoevents").Unsubscribe;
|
|
81
|
-
};
|
|
82
57
|
authenticate(): ResultAsync<StoredUserSession | null, Error>;
|
|
83
58
|
abortAuthentication(): void;
|
|
84
59
|
};
|
package/dist/sso/auth/impl.js
CHANGED
|
@@ -8,32 +8,11 @@ import { AbortError } from '../../helpers/abortError.js';
|
|
|
8
8
|
import { createState, readonly } from '../../helpers/state.js';
|
|
9
9
|
import { toError } from '../../helpers/utils.js';
|
|
10
10
|
import { createStoredUserSession } from '../userSessionRepository.js';
|
|
11
|
-
import { createAttestationService, createSudoAliceVerifier } from './attestationService.js';
|
|
12
11
|
import { HandshakeData, HandshakeResponsePayload, HandshakeResponseSensitiveData } from './scale/handshake.js';
|
|
13
|
-
export function createAuth({ metadata, hostMetadata, statementStore, ssoSessionRepository, userSecretRepository,
|
|
14
|
-
const attestationStatus = createState({ step: 'none' });
|
|
12
|
+
export function createAuth({ metadata, hostMetadata, statementStore, ssoSessionRepository, userSecretRepository, }) {
|
|
15
13
|
const pairingStatus = createState({ step: 'none' });
|
|
16
14
|
let authResult = null;
|
|
17
15
|
let abort = null;
|
|
18
|
-
function attestAccount(account, signal) {
|
|
19
|
-
const attestationService = createAttestationService(lazyClient);
|
|
20
|
-
const verifier = createSudoAliceVerifier();
|
|
21
|
-
const username = attestationService.claimUsername();
|
|
22
|
-
attestationStatus.write({ step: 'attestation', username });
|
|
23
|
-
return attestationService
|
|
24
|
-
.grantVerifierAllowance(verifier)
|
|
25
|
-
.andThrough(() => processSignal(signal))
|
|
26
|
-
.andThen(() => attestationService.registerLitePerson(username, account, verifier))
|
|
27
|
-
.andThrough(() => processSignal(signal))
|
|
28
|
-
.andTee(() => {
|
|
29
|
-
attestationStatus.write({ step: 'finished' });
|
|
30
|
-
})
|
|
31
|
-
.orTee(e => {
|
|
32
|
-
if (!(e instanceof AbortError)) {
|
|
33
|
-
attestationStatus.write({ step: 'attestationError', message: e.message });
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
16
|
function handshake(account, signal) {
|
|
38
17
|
const localAccount = createLocalSessionAccount(createAccountId(account.publicKey));
|
|
39
18
|
pairingStatus.write({ step: 'initial' });
|
|
@@ -84,17 +63,14 @@ export function createAuth({ metadata, hostMetadata, statementStore, ssoSessionR
|
|
|
84
63
|
}
|
|
85
64
|
const authModule = {
|
|
86
65
|
pairingStatus: readonly(pairingStatus),
|
|
87
|
-
attestationStatus: readonly(attestationStatus),
|
|
88
66
|
authenticate() {
|
|
89
67
|
if (authResult) {
|
|
90
68
|
return authResult;
|
|
91
69
|
}
|
|
92
70
|
abort = new AbortController();
|
|
93
71
|
const account = deriveSr25519Account(generateMnemonic(), '//wallet//sso');
|
|
94
|
-
authResult =
|
|
95
|
-
.andThen((
|
|
96
|
-
// Save secrets and sso session only after attestation has finished
|
|
97
|
-
const { session, secretsPayload } = handshakeResult;
|
|
72
|
+
authResult = handshake(account, abort.signal)
|
|
73
|
+
.andThen(({ session, secretsPayload }) => {
|
|
98
74
|
return userSecretRepository
|
|
99
75
|
.write(secretsPayload.id, {
|
|
100
76
|
ssSecret: secretsPayload.ssSecret,
|
|
@@ -121,7 +97,6 @@ export function createAuth({ metadata, hostMetadata, statementStore, ssoSessionR
|
|
|
121
97
|
}
|
|
122
98
|
authResult = null;
|
|
123
99
|
pairingStatus.reset();
|
|
124
|
-
attestationStatus.reset();
|
|
125
100
|
},
|
|
126
101
|
};
|
|
127
102
|
return authModule;
|
package/dist/sso/auth/types.d.ts
CHANGED
|
@@ -3,11 +3,12 @@ export type PairingStatus = {
|
|
|
3
3
|
step: 'none';
|
|
4
4
|
} | {
|
|
5
5
|
step: 'initial';
|
|
6
|
-
} | {
|
|
7
|
-
step: 'attestation';
|
|
8
6
|
} | {
|
|
9
7
|
step: 'pairing';
|
|
10
8
|
payload: string;
|
|
9
|
+
} | {
|
|
10
|
+
step: 'pending';
|
|
11
|
+
stage: string;
|
|
11
12
|
} | {
|
|
12
13
|
step: 'pairingError';
|
|
13
14
|
message: string;
|
|
@@ -15,14 +16,3 @@ export type PairingStatus = {
|
|
|
15
16
|
step: 'finished';
|
|
16
17
|
session: StoredUserSession;
|
|
17
18
|
};
|
|
18
|
-
export type AttestationStatus = {
|
|
19
|
-
step: 'none';
|
|
20
|
-
} | {
|
|
21
|
-
step: 'attestation';
|
|
22
|
-
username: string;
|
|
23
|
-
} | {
|
|
24
|
-
step: 'attestationError';
|
|
25
|
-
message: string;
|
|
26
|
-
} | {
|
|
27
|
-
step: 'finished';
|
|
28
|
-
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-papp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.9-
|
|
4
|
+
"version": "0.7.9-4",
|
|
5
5
|
"description": "Polkadot app integration",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -29,17 +29,16 @@
|
|
|
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.9-
|
|
33
|
-
"@novasamatech/scale": "0.7.9-
|
|
34
|
-
"@novasamatech/statement-store": "0.7.9-
|
|
35
|
-
"@novasamatech/storage-adapter": "0.7.9-
|
|
32
|
+
"@novasamatech/host-api": "0.7.9-4",
|
|
33
|
+
"@novasamatech/scale": "0.7.9-4",
|
|
34
|
+
"@novasamatech/statement-store": "0.7.9-4",
|
|
35
|
+
"@novasamatech/storage-adapter": "0.7.9-4",
|
|
36
36
|
"@polkadot-labs/hdkd-helpers": "^0.0.30",
|
|
37
37
|
"nanoevents": "9.1.0",
|
|
38
38
|
"nanoid": "5.1.9",
|
|
39
39
|
"neverthrow": "^8.2.0",
|
|
40
40
|
"polkadot-api": ">=2",
|
|
41
|
-
"scale-ts": "1.6.1"
|
|
42
|
-
"verifiablejs": "1.2.0"
|
|
41
|
+
"scale-ts": "1.6.1"
|
|
43
42
|
},
|
|
44
43
|
"publishConfig": {
|
|
45
44
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function callbackRaceResolver<T, R>(callback: (value: R) => unknown, preprocess: (value: T) => PromiseLike<R>): (value: T) => unknown;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function callbackRaceResolver(callback, preprocess) {
|
|
2
|
-
let abort = new AbortController();
|
|
3
|
-
return async (value) => {
|
|
4
|
-
abort.abort();
|
|
5
|
-
abort = new AbortController();
|
|
6
|
-
try {
|
|
7
|
-
const result = await preprocess(value);
|
|
8
|
-
if (abort.signal.aborted) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
callback(result);
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
/* empty */
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const hexCodec: import("scale-ts").Codec<`0x${string}`>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { CodecType } from 'scale-ts';
|
|
2
|
-
export type SignPayloadRequest = CodecType<typeof SignPayloadRequestCodec>;
|
|
3
|
-
export declare const SignPayloadRequestCodec: import("scale-ts").Codec<{
|
|
4
|
-
address: string;
|
|
5
|
-
blockHash: `0x${string}`;
|
|
6
|
-
blockNumber: `0x${string}`;
|
|
7
|
-
era: `0x${string}`;
|
|
8
|
-
genesisHash: `0x${string}`;
|
|
9
|
-
method: `0x${string}`;
|
|
10
|
-
nonce: `0x${string}`;
|
|
11
|
-
specVersion: `0x${string}`;
|
|
12
|
-
tip: `0x${string}`;
|
|
13
|
-
transactionVersion: `0x${string}`;
|
|
14
|
-
signedExtensions: string[];
|
|
15
|
-
version: number;
|
|
16
|
-
assetId: `0x${string}` | undefined;
|
|
17
|
-
metadataHash: `0x${string}` | undefined;
|
|
18
|
-
mode: number | undefined;
|
|
19
|
-
withSignedTransaction: boolean | undefined;
|
|
20
|
-
}>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Hex } from '@novasamatech/scale';
|
|
2
|
-
import { Option, Struct, Vector, bool, str, u32 } from 'scale-ts';
|
|
3
|
-
export const SignPayloadRequestCodec = Struct({
|
|
4
|
-
address: str,
|
|
5
|
-
blockHash: Hex(),
|
|
6
|
-
blockNumber: Hex(),
|
|
7
|
-
era: Hex(),
|
|
8
|
-
genesisHash: Hex(),
|
|
9
|
-
method: Hex(),
|
|
10
|
-
nonce: Hex(),
|
|
11
|
-
specVersion: Hex(),
|
|
12
|
-
tip: Hex(),
|
|
13
|
-
transactionVersion: Hex(),
|
|
14
|
-
signedExtensions: Vector(str),
|
|
15
|
-
version: u32,
|
|
16
|
-
assetId: Option(Hex()),
|
|
17
|
-
metadataHash: Option(Hex()),
|
|
18
|
-
mode: Option(u32),
|
|
19
|
-
withSignedTransaction: Option(bool),
|
|
20
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CodecType } from 'scale-ts';
|
|
2
|
-
export type SignPayloadResponseData = CodecType<typeof SignPayloadResponseDataCodec>;
|
|
3
|
-
export declare const SignPayloadResponseDataCodec: import("scale-ts").Codec<{
|
|
4
|
-
signature: Uint8Array<ArrayBufferLike>;
|
|
5
|
-
signedTransaction: Uint8Array<ArrayBufferLike> | undefined;
|
|
6
|
-
}>;
|
|
7
|
-
export type SignPayloadResponse = CodecType<typeof SignPayloadResponseCodec>;
|
|
8
|
-
export declare const SignPayloadResponseCodec: import("scale-ts").Codec<{
|
|
9
|
-
respondingTo: string;
|
|
10
|
-
payload: import("scale-ts").ResultPayload<{
|
|
11
|
-
signature: Uint8Array<ArrayBufferLike>;
|
|
12
|
-
signedTransaction: Uint8Array<ArrayBufferLike> | undefined;
|
|
13
|
-
}, string>;
|
|
14
|
-
}>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Bytes, Option, Result, Struct, str } from 'scale-ts';
|
|
2
|
-
export const SignPayloadResponseDataCodec = Struct({
|
|
3
|
-
signature: Bytes(),
|
|
4
|
-
signedTransaction: Option(Bytes()),
|
|
5
|
-
});
|
|
6
|
-
export const SignPayloadResponseCodec = Struct({
|
|
7
|
-
// referencing to RemoteMessage.messageId
|
|
8
|
-
respondingTo: str,
|
|
9
|
-
payload: Result(SignPayloadResponseDataCodec, str),
|
|
10
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|