@novasamatech/host-papp 0.6.6-1 → 0.6.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.
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/papp.d.ts +9 -2
- package/dist/papp.js +12 -3
- package/dist/sso/auth/impl.d.ts +7 -1
- package/dist/sso/auth/impl.js +15 -2
- package/dist/sso/auth/scale/handshake.d.ts +8 -1
- package/dist/sso/auth/scale/handshake.js +10 -2
- package/dist/sso/userSessionRepository.d.ts +1 -1
- package/package.json +9 -8
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export const SS_UNSTABLE_STAGE_ENDPOINTS = ['wss://pop-testnet.parity-lab.parity.io:443/9910'];
|
|
2
2
|
export const SS_STABLE_STAGE_ENDPOINTS = ['wss://pop3-testnet.parity-lab.parity.io/people'];
|
|
3
3
|
export const SS_PREVIEW_STAGE_ENDPOINTS = ['wss://previewnet.substrate.dev/people'];
|
|
4
|
+
export const SS_PASEO_STABLE_STAGE_ENDPOINTS = ['wss://paseo-people-unstable-rpc.polkadot.io'];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { SS_PREVIEW_STAGE_ENDPOINTS, SS_STABLE_STAGE_ENDPOINTS, SS_UNSTABLE_STAGE_ENDPOINTS } from './constants.js';
|
|
1
|
+
export { SS_PASEO_STABLE_STAGE_ENDPOINTS, 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
|
+
export type { HostMetadata } from './sso/auth/impl.js';
|
|
4
5
|
export type { AttestationStatus, PairingStatus } from './sso/auth/types.js';
|
|
5
6
|
export type { UserSession } from './sso/sessionManager/userSession.js';
|
|
6
7
|
export type { StoredUserSession } from './sso/userSessionRepository.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { SS_PREVIEW_STAGE_ENDPOINTS, SS_STABLE_STAGE_ENDPOINTS, SS_UNSTABLE_STAGE_ENDPOINTS } from './constants.js';
|
|
1
|
+
export { SS_PASEO_STABLE_STAGE_ENDPOINTS, SS_PREVIEW_STAGE_ENDPOINTS, SS_STABLE_STAGE_ENDPOINTS, SS_UNSTABLE_STAGE_ENDPOINTS, } from './constants.js';
|
|
2
2
|
export { createPappAdapter } from './papp.js';
|
package/dist/papp.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { LazyClient, StatementStoreAdapter } from '@novasamatech/statement-store';
|
|
2
2
|
import type { StorageAdapter } from '@novasamatech/storage-adapter';
|
|
3
3
|
import type { IdentityAdapter, IdentityRepository } from './identity/types.js';
|
|
4
|
-
import type { AuthComponent } from './sso/auth/impl.js';
|
|
4
|
+
import type { AuthComponent, HostMetadata } from './sso/auth/impl.js';
|
|
5
5
|
import type { SsoSessionManager } from './sso/sessionManager/impl.js';
|
|
6
|
+
import type { UserSecretRepository } from './sso/userSecretRepository.js';
|
|
6
7
|
export type PappAdapter = {
|
|
7
8
|
sso: AuthComponent;
|
|
8
9
|
sessions: SsoSessionManager;
|
|
10
|
+
secrets: UserSecretRepository;
|
|
9
11
|
identity: IdentityRepository;
|
|
10
12
|
};
|
|
11
13
|
type Adapters = {
|
|
@@ -31,7 +33,12 @@ type Params = {
|
|
|
31
33
|
* ```
|
|
32
34
|
*/
|
|
33
35
|
metadata: string;
|
|
36
|
+
/**
|
|
37
|
+
* Optional host environment metadata for Sign-In confirmation screen.
|
|
38
|
+
* All fields are optional - absence must not break the pairing flow.
|
|
39
|
+
*/
|
|
40
|
+
hostMetadata?: HostMetadata;
|
|
34
41
|
adapters?: Partial<Adapters>;
|
|
35
42
|
};
|
|
36
|
-
export declare function createPappAdapter({ appId, metadata, adapters }: Params): PappAdapter;
|
|
43
|
+
export declare function createPappAdapter({ appId, metadata, hostMetadata, adapters }: Params): PappAdapter;
|
|
37
44
|
export {};
|
package/dist/papp.js
CHANGED
|
@@ -8,16 +8,25 @@ import { createAuth } from './sso/auth/impl.js';
|
|
|
8
8
|
import { createSsoSessionManager } from './sso/sessionManager/impl.js';
|
|
9
9
|
import { createUserSecretRepository } from './sso/userSecretRepository.js';
|
|
10
10
|
import { createUserSessionRepository } from './sso/userSessionRepository.js';
|
|
11
|
-
export function createPappAdapter({ appId, metadata, adapters }) {
|
|
12
|
-
const lazyClient = adapters?.lazyClient ??
|
|
11
|
+
export function createPappAdapter({ appId, metadata, hostMetadata, adapters }) {
|
|
12
|
+
const lazyClient = adapters?.lazyClient ??
|
|
13
|
+
createLazyClient(getWsProvider(SS_STABLE_STAGE_ENDPOINTS, { heartbeatTimeout: Number.POSITIVE_INFINITY }));
|
|
13
14
|
const statementStore = adapters?.statementStore ?? createPapiStatementStoreAdapter(lazyClient);
|
|
14
15
|
const identities = adapters?.identities ?? createIdentityRpcAdapter(lazyClient);
|
|
15
16
|
const storage = adapters?.storage ?? createLocalStorageAdapter(appId);
|
|
16
17
|
const ssoSessionRepository = createUserSessionRepository(storage);
|
|
17
18
|
const userSecretRepository = createUserSecretRepository(appId, storage);
|
|
18
19
|
return {
|
|
19
|
-
sso: createAuth({
|
|
20
|
+
sso: createAuth({
|
|
21
|
+
metadata,
|
|
22
|
+
hostMetadata,
|
|
23
|
+
statementStore,
|
|
24
|
+
ssoSessionRepository,
|
|
25
|
+
userSecretRepository,
|
|
26
|
+
lazyClient,
|
|
27
|
+
}),
|
|
20
28
|
sessions: createSsoSessionManager({ storage, statementStore, ssoSessionRepository, userSecretRepository }),
|
|
29
|
+
secrets: userSecretRepository,
|
|
21
30
|
identity: createIdentityRepository({ adapter: identities, storage }),
|
|
22
31
|
};
|
|
23
32
|
}
|
package/dist/sso/auth/impl.d.ts
CHANGED
|
@@ -3,14 +3,20 @@ import { ResultAsync } from 'neverthrow';
|
|
|
3
3
|
import type { UserSecretRepository } from '../userSecretRepository.js';
|
|
4
4
|
import type { StoredUserSession, UserSessionRepository } from '../userSessionRepository.js';
|
|
5
5
|
export type AuthComponent = ReturnType<typeof createAuth>;
|
|
6
|
+
export type HostMetadata = {
|
|
7
|
+
hostVersion?: string;
|
|
8
|
+
osType?: string;
|
|
9
|
+
osVersion?: string;
|
|
10
|
+
};
|
|
6
11
|
type Params = {
|
|
7
12
|
metadata: string;
|
|
13
|
+
hostMetadata?: HostMetadata;
|
|
8
14
|
statementStore: StatementStoreAdapter;
|
|
9
15
|
ssoSessionRepository: UserSessionRepository;
|
|
10
16
|
userSecretRepository: UserSecretRepository;
|
|
11
17
|
lazyClient: LazyClient;
|
|
12
18
|
};
|
|
13
|
-
export declare function createAuth({ metadata, statementStore, ssoSessionRepository, userSecretRepository, lazyClient, }: Params): {
|
|
19
|
+
export declare function createAuth({ metadata, hostMetadata, statementStore, ssoSessionRepository, userSecretRepository, lazyClient, }: Params): {
|
|
14
20
|
pairingStatus: {
|
|
15
21
|
read: () => {
|
|
16
22
|
step: "none";
|
package/dist/sso/auth/impl.js
CHANGED
|
@@ -10,7 +10,7 @@ import { toError } from '../../helpers/utils.js';
|
|
|
10
10
|
import { createStoredUserSession } from '../userSessionRepository.js';
|
|
11
11
|
import { createAttestationService, createSudoAliceVerifier } from './attestationService.js';
|
|
12
12
|
import { HandshakeData, HandshakeResponsePayload, HandshakeResponseSensitiveData } from './scale/handshake.js';
|
|
13
|
-
export function createAuth({ metadata, statementStore, ssoSessionRepository, userSecretRepository, lazyClient, }) {
|
|
13
|
+
export function createAuth({ metadata, hostMetadata, statementStore, ssoSessionRepository, userSecretRepository, lazyClient, }) {
|
|
14
14
|
const attestationStatus = createState({ step: 'none' });
|
|
15
15
|
const pairingStatus = createState({ step: 'none' });
|
|
16
16
|
let authResult = null;
|
|
@@ -42,6 +42,7 @@ export function createAuth({ metadata, statementStore, ssoSessionRepository, use
|
|
|
42
42
|
ssPublicKey: account.publicKey,
|
|
43
43
|
encrPublicKey: publicKey,
|
|
44
44
|
metadata,
|
|
45
|
+
hostMetadata,
|
|
45
46
|
}));
|
|
46
47
|
const handshakeTopic = encrKeys.andThen(({ publicKey }) => createHandshakeTopic(localAccount, publicKey));
|
|
47
48
|
const dataPrepared = Result.combine([handshakePayload, handshakeTopic, encrKeys]).andTee(([payload]) => pairingStatus.write({ step: 'pairing', payload: createDeeplink(payload) }));
|
|
@@ -126,7 +127,19 @@ export function createAuth({ metadata, statementStore, ssoSessionRepository, use
|
|
|
126
127
|
return authModule;
|
|
127
128
|
}
|
|
128
129
|
const createHandshakeTopic = fromThrowable((account, encrPublicKey) => khash(account.accountId, mergeUint8([encrPublicKey, stringToBytes('topic')])), toError);
|
|
129
|
-
const createHandshakePayloadV1 = fromThrowable(({ encrPublicKey, ssPublicKey, metadata, }) =>
|
|
130
|
+
const createHandshakePayloadV1 = fromThrowable(({ encrPublicKey, ssPublicKey, metadata, hostMetadata, }) => {
|
|
131
|
+
const hostVersion = hostMetadata?.hostVersion;
|
|
132
|
+
const osType = hostMetadata?.osType;
|
|
133
|
+
const osVersion = hostMetadata?.osVersion;
|
|
134
|
+
return HandshakeData.enc(enumValue('v1', {
|
|
135
|
+
ssPublicKey,
|
|
136
|
+
encrPublicKey,
|
|
137
|
+
metadata,
|
|
138
|
+
hostVersion,
|
|
139
|
+
osType,
|
|
140
|
+
osVersion,
|
|
141
|
+
}));
|
|
142
|
+
}, toError);
|
|
130
143
|
function parseHandshakePayload(payload) {
|
|
131
144
|
const decoded = HandshakeResponsePayload.dec(payload);
|
|
132
145
|
switch (decoded.tag) {
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export declare const HandshakeData: import("scale-ts").Codec<{
|
|
2
2
|
tag: "v1";
|
|
3
|
-
value:
|
|
3
|
+
value: {
|
|
4
|
+
ssPublicKey: import("../../../crypto.js").SsPublicKey;
|
|
5
|
+
encrPublicKey: import("../../../crypto.js").EncrPublicKey;
|
|
6
|
+
metadata: string;
|
|
7
|
+
hostVersion: string | undefined;
|
|
8
|
+
osType: string | undefined;
|
|
9
|
+
osVersion: string | undefined;
|
|
10
|
+
};
|
|
4
11
|
}>;
|
|
5
12
|
export declare const HandshakeResponsePayload: import("scale-ts").Codec<{
|
|
6
13
|
tag: "v1";
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { Enum } from '@novasamatech/scale';
|
|
2
|
-
import { Bytes, Struct, Tuple, str } from 'scale-ts';
|
|
2
|
+
import { Bytes, Option, Struct, Tuple, str } from 'scale-ts';
|
|
3
3
|
import { EncrPubKey, SsPubKey } from '../../../crypto.js';
|
|
4
|
+
const optStr = Option(str);
|
|
4
5
|
export const HandshakeData = Enum({
|
|
5
|
-
v1:
|
|
6
|
+
v1: Struct({
|
|
7
|
+
ssPublicKey: SsPubKey,
|
|
8
|
+
encrPublicKey: EncrPubKey,
|
|
9
|
+
metadata: str,
|
|
10
|
+
hostVersion: optStr,
|
|
11
|
+
osType: optStr,
|
|
12
|
+
osVersion: optStr,
|
|
13
|
+
}),
|
|
6
14
|
});
|
|
7
15
|
export const HandshakeResponsePayload = Enum({
|
|
8
16
|
v1: Struct({ encrypted: Bytes(), tmpKey: Bytes(65) }),
|
|
@@ -12,7 +12,7 @@ export declare const createUserSessionRepository: (storage: StorageAdapter) => {
|
|
|
12
12
|
filter(fn: (value: StoredUserSession) => boolean): import("neverthrow").ResultAsync<StoredUserSession[], Error>;
|
|
13
13
|
mutate(fn: (value: StoredUserSession[]) => StoredUserSession[]): import("neverthrow").ResultAsync<StoredUserSession[], Error>;
|
|
14
14
|
read(): import("neverthrow").ResultAsync<StoredUserSession[], Error>;
|
|
15
|
-
write(value: StoredUserSession[]): import("neverthrow").ResultAsync<
|
|
15
|
+
write(value: StoredUserSession[]): import("neverthrow").ResultAsync<null, Error> | import("neverthrow").ResultAsync<StoredUserSession[], Error>;
|
|
16
16
|
clear(): import("neverthrow").ResultAsync<void, Error>;
|
|
17
17
|
subscribe(fn: (value: StoredUserSession[]) => void): VoidFunction;
|
|
18
18
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-papp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.7",
|
|
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/paritytech/triangle-js-sdks.git"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
12
|
"polkadot"
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"exports": {
|
|
16
16
|
"./package.json": "./package.json",
|
|
17
17
|
".": {
|
|
18
|
+
"#/source": "./src/index.ts",
|
|
18
19
|
"types": "./dist/index.d.ts",
|
|
19
20
|
"default": "./dist/index.js"
|
|
20
21
|
}
|
|
@@ -28,16 +29,16 @@
|
|
|
28
29
|
"@noble/ciphers": "2.1.1",
|
|
29
30
|
"@noble/curves": "2.0.1",
|
|
30
31
|
"@noble/hashes": "2.0.1",
|
|
31
|
-
"@novasamatech/host-api": "0.6.
|
|
32
|
-
"@novasamatech/scale": "0.6.
|
|
33
|
-
"@novasamatech/statement-store": "0.6.
|
|
34
|
-
"@novasamatech/storage-adapter": "0.6.
|
|
32
|
+
"@novasamatech/host-api": "0.6.7",
|
|
33
|
+
"@novasamatech/scale": "0.6.7",
|
|
34
|
+
"@novasamatech/statement-store": "0.6.7",
|
|
35
|
+
"@novasamatech/storage-adapter": "0.6.7",
|
|
35
36
|
"@polkadot-api/utils": "0.2.0",
|
|
36
37
|
"@polkadot-api/substrate-bindings": "^0.17.0",
|
|
37
|
-
"@polkadot-labs/hdkd-helpers": "^0.0.
|
|
38
|
+
"@polkadot-labs/hdkd-helpers": "^0.0.28",
|
|
38
39
|
"@scure/sr25519": "1.0.0",
|
|
39
40
|
"nanoevents": "9.1.0",
|
|
40
|
-
"nanoid": "5.1.
|
|
41
|
+
"nanoid": "5.1.7",
|
|
41
42
|
"neverthrow": "^8.2.0",
|
|
42
43
|
"polkadot-api": "^1.23.3",
|
|
43
44
|
"scale-ts": "1.6.1",
|