@novasamatech/host-papp 0.6.2-0 → 0.6.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/constants.js +1 -4
- package/dist/index.d.ts +2 -2
- package/dist/sso/auth/impl.js +21 -11
- package/dist/sso/sessionManager/scale/remoteMessage.d.ts +1 -1
- package/dist/sso/sessionManager/scale/signingRequest.d.ts +4 -3
- package/dist/sso/sessionManager/scale/signingRequest.js +3 -3
- package/dist/sso/sessionManager/scale/signingResponse.d.ts +3 -3
- package/dist/sso/sessionManager/scale/signingResponse.js +2 -2
- package/dist/sso/sessionManager/userSession.d.ts +4 -4
- package/package.json +5 -5
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'];
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export type { AttestationStatus, PairingStatus } from './sso/auth/types.js';
|
|
|
5
5
|
export type { UserSession } from './sso/sessionManager/userSession.js';
|
|
6
6
|
export type { StoredUserSession } from './sso/userSessionRepository.js';
|
|
7
7
|
export type { Identity } from './identity/types.js';
|
|
8
|
-
export type {
|
|
9
|
-
export type {
|
|
8
|
+
export type { SigningPayloadRequest, SigningRawRequest, SigningRequest, } from './sso/sessionManager/scale/signingRequest.js';
|
|
9
|
+
export type { SigningPayloadResponse } from './sso/sessionManager/scale/signingResponse.js';
|
package/dist/sso/auth/impl.js
CHANGED
|
@@ -61,19 +61,18 @@ export function createAuth({ metadata, statementStore, ssoSessionRepository, use
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
|
-
const
|
|
65
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
.
|
|
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;
|
|
@@ -27,7 +27,7 @@ export declare const RemoteMessageCodec: import("scale-ts").Codec<{
|
|
|
27
27
|
assetId: `0x${string}` | undefined;
|
|
28
28
|
metadataHash: `0x${string}` | undefined;
|
|
29
29
|
mode: number | undefined;
|
|
30
|
-
withSignedTransaction: boolean |
|
|
30
|
+
withSignedTransaction: boolean | void;
|
|
31
31
|
};
|
|
32
32
|
} | {
|
|
33
33
|
tag: "Raw";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CodecType } from 'scale-ts';
|
|
2
|
-
export type
|
|
2
|
+
export type SigningPayloadRequest = CodecType<typeof SigningPayloadRequestCodec>;
|
|
3
3
|
export declare const SigningPayloadRequestCodec: import("scale-ts").Codec<{
|
|
4
4
|
address: string;
|
|
5
5
|
blockHash: `0x${string}`;
|
|
@@ -16,7 +16,7 @@ export declare const SigningPayloadRequestCodec: import("scale-ts").Codec<{
|
|
|
16
16
|
assetId: `0x${string}` | undefined;
|
|
17
17
|
metadataHash: `0x${string}` | undefined;
|
|
18
18
|
mode: number | undefined;
|
|
19
|
-
withSignedTransaction: boolean |
|
|
19
|
+
withSignedTransaction: boolean | void;
|
|
20
20
|
}>;
|
|
21
21
|
export type SigningRawRequest = CodecType<typeof SigningRawRequestCodec>;
|
|
22
22
|
export declare const SigningRawRequestCodec: import("scale-ts").Codec<{
|
|
@@ -29,6 +29,7 @@ export declare const SigningRawRequestCodec: import("scale-ts").Codec<{
|
|
|
29
29
|
value: string;
|
|
30
30
|
};
|
|
31
31
|
}>;
|
|
32
|
+
export type SigningRequest = CodecType<typeof SigningRequestCodec>;
|
|
32
33
|
export declare const SigningRequestCodec: import("scale-ts").Codec<{
|
|
33
34
|
tag: "Payload";
|
|
34
35
|
value: {
|
|
@@ -47,7 +48,7 @@ export declare const SigningRequestCodec: import("scale-ts").Codec<{
|
|
|
47
48
|
assetId: `0x${string}` | undefined;
|
|
48
49
|
metadataHash: `0x${string}` | undefined;
|
|
49
50
|
mode: number | undefined;
|
|
50
|
-
withSignedTransaction: boolean |
|
|
51
|
+
withSignedTransaction: boolean | void;
|
|
51
52
|
};
|
|
52
53
|
} | {
|
|
53
54
|
tag: "Raw";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Enum, Hex } from '@novasamatech/scale';
|
|
2
|
-
import { Bytes, Option, Struct, Vector,
|
|
1
|
+
import { Enum, Hex, OptionBool } from '@novasamatech/scale';
|
|
2
|
+
import { Bytes, Option, Struct, Vector, str, u32 } from 'scale-ts';
|
|
3
3
|
export const SigningPayloadRequestCodec = Struct({
|
|
4
4
|
address: str,
|
|
5
5
|
blockHash: Hex(),
|
|
@@ -16,7 +16,7 @@ export const SigningPayloadRequestCodec = Struct({
|
|
|
16
16
|
assetId: Option(Hex()),
|
|
17
17
|
metadataHash: Option(Hex()),
|
|
18
18
|
mode: Option(u32),
|
|
19
|
-
withSignedTransaction:
|
|
19
|
+
withSignedTransaction: OptionBool,
|
|
20
20
|
});
|
|
21
21
|
export const SigningRawRequestCodec = Struct({
|
|
22
22
|
address: str,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { CodecType } from 'scale-ts';
|
|
2
|
-
export type
|
|
3
|
-
export declare const
|
|
2
|
+
export type SigningPayloadResponseData = CodecType<typeof SigningPayloadResponseDataCodec>;
|
|
3
|
+
export declare const SigningPayloadResponseDataCodec: import("scale-ts").Codec<{
|
|
4
4
|
signature: Uint8Array<ArrayBufferLike>;
|
|
5
5
|
signedTransaction: Uint8Array<ArrayBufferLike> | undefined;
|
|
6
6
|
}>;
|
|
7
|
-
export type
|
|
7
|
+
export type SigningPayloadResponse = CodecType<typeof SigningResponseCodec>;
|
|
8
8
|
export declare const SigningResponseCodec: import("scale-ts").Codec<{
|
|
9
9
|
respondingTo: string;
|
|
10
10
|
payload: import("scale-ts").ResultPayload<{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Bytes, Option, Result, Struct, str } from 'scale-ts';
|
|
2
|
-
export const
|
|
2
|
+
export const SigningPayloadResponseDataCodec = Struct({
|
|
3
3
|
signature: Bytes(),
|
|
4
4
|
signedTransaction: Option(Bytes()),
|
|
5
5
|
});
|
|
6
6
|
export const SigningResponseCodec = Struct({
|
|
7
7
|
// referencing to RemoteMessage.messageId
|
|
8
8
|
respondingTo: str,
|
|
9
|
-
payload: Result(
|
|
9
|
+
payload: Result(SigningPayloadResponseDataCodec, str),
|
|
10
10
|
});
|
|
@@ -5,12 +5,12 @@ import type { CodecType } from 'scale-ts';
|
|
|
5
5
|
import type { Callback } from '../../types.js';
|
|
6
6
|
import type { StoredUserSession } from '../userSessionRepository.js';
|
|
7
7
|
import { RemoteMessageCodec } from './scale/remoteMessage.js';
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
8
|
+
import type { SigningPayloadRequest, SigningRawRequest } from './scale/signingRequest.js';
|
|
9
|
+
import type { SigningPayloadResponseData } from './scale/signingResponse.js';
|
|
10
10
|
export type UserSession = StoredUserSession & {
|
|
11
11
|
sendDisconnectMessage(): ResultAsync<void, Error>;
|
|
12
|
-
signPayload(payload:
|
|
13
|
-
signRaw(payload: SigningRawRequest): ResultAsync<
|
|
12
|
+
signPayload(payload: SigningPayloadRequest): ResultAsync<SigningPayloadResponseData, Error>;
|
|
13
|
+
signRaw(payload: SigningRawRequest): ResultAsync<SigningPayloadResponseData, Error>;
|
|
14
14
|
subscribe(callback: Callback<CodecType<typeof RemoteMessageCodec>, ResultAsync<boolean, Error>>): VoidFunction;
|
|
15
15
|
dispose(): void;
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-papp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.4",
|
|
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.
|
|
32
|
-
"@novasamatech/scale": "0.6.
|
|
33
|
-
"@novasamatech/statement-store": "0.6.
|
|
34
|
-
"@novasamatech/storage-adapter": "0.6.
|
|
31
|
+
"@novasamatech/host-api": "0.6.4",
|
|
32
|
+
"@novasamatech/scale": "0.6.4",
|
|
33
|
+
"@novasamatech/statement-store": "0.6.4",
|
|
34
|
+
"@novasamatech/storage-adapter": "0.6.4",
|
|
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",
|