@novasamatech/host-papp 0.5.0-17 → 0.5.0-19
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/.papi/descriptors/generated.json +1 -0
- package/dist/crypto.d.ts +2 -2
- package/dist/crypto.js +8 -7
- package/dist/helpers/abortError.d.ts +0 -1
- package/dist/helpers/abortError.js +0 -3
- package/dist/index.d.ts +1 -1
- package/dist/papp.js +2 -2
- package/dist/sso/auth/attestationService.js +1 -1
- package/dist/sso/auth/impl.d.ts +29 -3
- package/dist/sso/auth/impl.js +60 -35
- package/dist/sso/auth/types.d.ts +13 -2
- package/dist/sso/userSecretRepository.d.ts +1 -1
- package/dist/sso/userSecretRepository.js +2 -2
- package/package.json +5 -5
- package/dist/adapters/identity/rpc.d.ts +0 -6
- package/dist/adapters/identity/rpc.js +0 -101
- package/dist/adapters/identity/types.d.ts +0 -10
- package/dist/adapters/identity/types.js +0 -1
- package/dist/adapters/lazyClient/papi.d.ts +0 -3
- package/dist/adapters/lazyClient/papi.js +0 -17
- package/dist/adapters/lazyClient/types.d.ts +0 -5
- package/dist/adapters/lazyClient/types.js +0 -1
- package/dist/adapters/statement/rpc.d.ts +0 -3
- package/dist/adapters/statement/rpc.js +0 -93
- package/dist/adapters/statement/types.d.ts +0 -9
- package/dist/adapters/statement/types.js +0 -1
- package/dist/adapters/storage/localStorage.d.ts +0 -2
- package/dist/adapters/storage/localStorage.js +0 -34
- package/dist/adapters/storage/memory.d.ts +0 -2
- package/dist/adapters/storage/memory.js +0 -22
- package/dist/adapters/storage/types.d.ts +0 -7
- package/dist/adapters/storage/types.js +0 -1
- package/dist/adapters/transport/rpc.d.ts +0 -3
- package/dist/adapters/transport/rpc.js +0 -51
- package/dist/adapters/transport/types.d.ts +0 -6
- package/dist/adapters/transport/types.js +0 -1
- package/dist/components/auth/codec.d.ts +0 -9
- package/dist/components/auth/codec.js +0 -10
- package/dist/components/auth/codecs.d.ts +0 -9
- package/dist/components/auth/codecs.js +0 -10
- package/dist/components/auth/index.d.ts +0 -36
- package/dist/components/auth/index.js +0 -150
- package/dist/components/auth/types.d.ts +0 -15
- package/dist/components/auth/types.js +0 -1
- package/dist/components/session.d.ts +0 -34
- package/dist/components/session.js +0 -54
- package/dist/components/sso/index.d.ts +0 -36
- package/dist/components/sso/index.js +0 -150
- package/dist/components/sso/scale/handshake.d.ts +0 -9
- package/dist/components/sso/scale/handshake.js +0 -10
- package/dist/components/sso/types.d.ts +0 -15
- package/dist/components/sso/types.js +0 -1
- package/dist/components/transport.d.ts +0 -27
- package/dist/components/transport.js +0 -57
- package/dist/components/user/codec.d.ts +0 -16
- package/dist/components/user/codec.js +0 -13
- package/dist/components/user/index.d.ts +0 -22
- package/dist/components/user/index.js +0 -58
- package/dist/components/user/ssoMessageStream.d.ts +0 -10
- package/dist/components/user/ssoMessageStream.js +0 -8
- package/dist/components/user/ssoSession.d.ts +0 -5
- package/dist/components/user/ssoSession.js +0 -5
- package/dist/components/user/storage.d.ts +0 -27
- package/dist/components/user/storage.js +0 -143
- package/dist/components/user/types.d.ts +0 -6
- package/dist/components/user/types.js +0 -1
- package/dist/components/user/userSessionStorage.d.ts +0 -20
- package/dist/components/user/userSessionStorage.js +0 -24
- package/dist/components/user.d.ts +0 -74
- package/dist/components/user.js +0 -188
- package/dist/helpers/result.d.ts +0 -12
- package/dist/helpers/result.js +0 -15
- package/dist/helpers/result.spec.d.ts +0 -1
- package/dist/helpers/result.spec.js +0 -23
- package/dist/helpers.d.ts +0 -1
- package/dist/helpers.js +0 -3
- package/dist/modules/accounts.d.ts +0 -1
- package/dist/modules/accounts.js +0 -2
- package/dist/modules/crypto.d.ts +0 -23
- package/dist/modules/crypto.js +0 -51
- package/dist/modules/secretStorage.d.ts +0 -15
- package/dist/modules/secretStorage.js +0 -44
- package/dist/modules/session/helpers.d.ts +0 -5
- package/dist/modules/session/helpers.js +0 -29
- package/dist/modules/session/session.d.ts +0 -12
- package/dist/modules/session/session.js +0 -50
- package/dist/modules/session/types.d.ts +0 -12
- package/dist/modules/session/types.js +0 -1
- package/dist/modules/signIn.d.ts +0 -67
- package/dist/modules/signIn.js +0 -188
- package/dist/modules/state.d.ts +0 -16
- package/dist/modules/state.js +0 -50
- package/dist/modules/statementStore.d.ts +0 -12
- package/dist/modules/statementStore.js +0 -22
- package/dist/modules/statementTopic.d.ts +0 -34
- package/dist/modules/statementTopic.js +0 -46
- package/dist/modules/storageView.d.ts +0 -25
- package/dist/modules/storageView.js +0 -51
- package/dist/modules/syncStorage.d.ts +0 -25
- package/dist/modules/syncStorage.js +0 -76
- package/dist/modules/transport/codec.d.ts +0 -24
- package/dist/modules/transport/codec.js +0 -36
- package/dist/modules/transport/crypto.d.ts +0 -2
- package/dist/modules/transport/crypto.js +0 -20
- package/dist/modules/transport/transport.d.ts +0 -42
- package/dist/modules/transport/transport.js +0 -66
- package/dist/modules/user.d.ts +0 -67
- package/dist/modules/user.js +0 -188
- package/dist/modules/userManager.d.ts +0 -15
- package/dist/modules/userManager.js +0 -105
- package/dist/modules/userStorage.d.ts +0 -19
- package/dist/modules/userStorage.js +0 -108
- package/dist/modules/userStore.d.ts +0 -15
- package/dist/modules/userStore.js +0 -105
- package/dist/sso/session/impl.d.ts +0 -23
- package/dist/sso/session/impl.js +0 -57
- package/dist/sso/session/scale/remoteMessage.d.ts +0 -10
- package/dist/sso/session/scale/remoteMessage.js +0 -13
- package/dist/sso/session/sessionManager.d.ts +0 -23
- package/dist/sso/session/sessionManager.js +0 -58
- package/dist/sso/session/ssoSession.d.ts +0 -8
- package/dist/sso/session/ssoSession.js +0 -5
- package/dist/sso/session/ssoSessionStorage.d.ts +0 -21
- package/dist/sso/session/ssoSessionStorage.js +0 -20
- package/dist/sso/session/types.d.ts +0 -6
- package/dist/sso/session/types.js +0 -1
- package/dist/sso/session/userSessionStorage.d.ts +0 -21
- package/dist/sso/session/userSessionStorage.js +0 -20
- package/dist/sso/sessionManager/attestationService.d.ts +0 -5
- package/dist/sso/sessionManager/attestationService.js +0 -15
- package/dist/sso/sessionManager/repository/ssoSessionRepository.d.ts +0 -22
- package/dist/sso/sessionManager/repository/ssoSessionRepository.js +0 -27
- package/dist/sso/sessionManager/scale/signRequest.d.ts +0 -19
- package/dist/sso/sessionManager/scale/signRequest.js +0 -19
- package/dist/sso/sessionManager/scale/signResponse.d.ts +0 -6
- package/dist/sso/sessionManager/scale/signResponse.js +0 -5
- package/dist/sso/sessionManager/ssoSession.d.ts +0 -23
- package/dist/sso/sessionManager/ssoSession.js +0 -69
- package/dist/sso/sessionManager/ssoSessionProver.d.ts +0 -4
- package/dist/sso/sessionManager/ssoSessionProver.js +0 -35
- package/dist/sso/ssoSessionRepository.d.ts +0 -18
- package/dist/sso/ssoSessionRepository.js +0 -27
- package/dist/structs.d.ts +0 -24
- package/dist/structs.js +0 -36
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { getStatementSigner, statementCodec } from '@polkadot-api/sdk-statement';
|
|
2
|
-
import { err, errAsync, fromThrowable, ok, okAsync } from 'neverthrow';
|
|
3
|
-
import { compact } from 'scale-ts';
|
|
4
|
-
import { toError } from '../../helpers/utils.js';
|
|
5
|
-
import { getSsPub, signWithSsSecret, verifyWithSsSecret } from '../../modules/crypto.js';
|
|
6
|
-
const verify = fromThrowable(verifyWithSsSecret, toError);
|
|
7
|
-
export function createSsoStatementProver(userSession, userSecretRepository) {
|
|
8
|
-
const secret = userSecretRepository
|
|
9
|
-
.read(userSession.id)
|
|
10
|
-
.andThen(secrets => (secrets ? ok(secrets) : err(new Error(`Secrets for session ${userSession.id} not found.`))))
|
|
11
|
-
.map(x => x.ssSecret);
|
|
12
|
-
return {
|
|
13
|
-
generateMessageProof(statement) {
|
|
14
|
-
return secret.map(secret => {
|
|
15
|
-
const signer = getStatementSigner(getSsPub(secret), 'sr25519', data => signWithSsSecret(secret, data));
|
|
16
|
-
return signer.sign(statement);
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
verifyMessageProof(statement) {
|
|
20
|
-
const { proof, ...unsigned } = statement;
|
|
21
|
-
if (!proof) {
|
|
22
|
-
// TODO should we pass check when proof is not presented?
|
|
23
|
-
return okAsync(true);
|
|
24
|
-
}
|
|
25
|
-
const encoded = statementCodec.enc(unsigned);
|
|
26
|
-
const compactLen = compact.enc(compact.dec(encoded)).length;
|
|
27
|
-
switch (proof.type) {
|
|
28
|
-
case 'sr25519':
|
|
29
|
-
return verify(encoded.slice(compactLen), proof.value.signature.asBytes(), proof.value.signer.asBytes()).asyncAndThen(x => okAsync(x));
|
|
30
|
-
default:
|
|
31
|
-
return errAsync(new Error(`Proof type ${proof.type} is not supported.`));
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { LocalSessionAccount, RemoteSessionAccount } from '@novasamatech/statement-store';
|
|
2
|
-
import type { StorageAdapter } from '@novasamatech/storage-adapter';
|
|
3
|
-
export type SsoSessionRepository = ReturnType<typeof createSsoSessionRepository>;
|
|
4
|
-
export type UserSession = {
|
|
5
|
-
id: string;
|
|
6
|
-
local: LocalSessionAccount;
|
|
7
|
-
remote: RemoteSessionAccount;
|
|
8
|
-
};
|
|
9
|
-
export declare function createUserSession(localAccount: LocalSessionAccount, remoteAccount: RemoteSessionAccount): UserSession;
|
|
10
|
-
export declare const createSsoSessionRepository: (storage: StorageAdapter) => {
|
|
11
|
-
add(value: UserSession): import("neverthrow").ResultAsync<UserSession, Error>;
|
|
12
|
-
filter(fn: (value: UserSession) => boolean): import("neverthrow").ResultAsync<UserSession[], Error>;
|
|
13
|
-
mutate(fn: (value: UserSession[]) => UserSession[]): import("neverthrow").ResultAsync<UserSession[], Error>;
|
|
14
|
-
read(): import("neverthrow").ResultAsync<UserSession[], Error>;
|
|
15
|
-
write(value: UserSession[]): import("neverthrow").ResultAsync<UserSession[], Error> | import("neverthrow").ResultAsync<null, Error>;
|
|
16
|
-
clear(): import("neverthrow").ResultAsync<void, Error>;
|
|
17
|
-
subscribe(fn: (value: UserSession[]) => void): VoidFunction;
|
|
18
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { LocalSessionAccountCodec, RemoteSessionAccountCodec } from '@novasamatech/statement-store';
|
|
2
|
-
import { fieldListView } from '@novasamatech/storage-adapter';
|
|
3
|
-
import { fromHex, toHex } from '@polkadot-api/utils';
|
|
4
|
-
import { nanoid } from 'nanoid';
|
|
5
|
-
import { Struct, Vector, str } from 'scale-ts';
|
|
6
|
-
const userSessionCodec = Struct({
|
|
7
|
-
id: str,
|
|
8
|
-
local: LocalSessionAccountCodec,
|
|
9
|
-
remote: RemoteSessionAccountCodec,
|
|
10
|
-
});
|
|
11
|
-
export function createUserSession(localAccount, remoteAccount) {
|
|
12
|
-
return {
|
|
13
|
-
id: nanoid(12),
|
|
14
|
-
local: localAccount,
|
|
15
|
-
remote: remoteAccount,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const userSessionsCodec = Vector(userSessionCodec);
|
|
19
|
-
export const createSsoSessionRepository = (storage) => {
|
|
20
|
-
return fieldListView({
|
|
21
|
-
storage,
|
|
22
|
-
key: 'SsoSessions',
|
|
23
|
-
initial: [],
|
|
24
|
-
from: x => userSessionsCodec.dec(fromHex(x)),
|
|
25
|
-
to: x => toHex(userSessionsCodec.enc(x)),
|
|
26
|
-
});
|
|
27
|
-
};
|
package/dist/structs.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Codec } from 'scale-ts';
|
|
2
|
-
export type TransportError = 'decryptionFailed' | 'decodingFailed' | 'unknown';
|
|
3
|
-
export declare const TransportErrorCodec: Codec<TransportError>;
|
|
4
|
-
export declare const Request: <T>(data: Codec<T>) => Codec<{
|
|
5
|
-
requestId: string;
|
|
6
|
-
data: T[];
|
|
7
|
-
}>;
|
|
8
|
-
export declare const Response: Codec<{
|
|
9
|
-
requestId: string;
|
|
10
|
-
responseCode: TransportError;
|
|
11
|
-
}>;
|
|
12
|
-
export declare const StatementData: <T>(data: Codec<T>) => Codec<{
|
|
13
|
-
tag: "request";
|
|
14
|
-
value: {
|
|
15
|
-
requestId: string;
|
|
16
|
-
data: T[];
|
|
17
|
-
};
|
|
18
|
-
} | {
|
|
19
|
-
tag: "response";
|
|
20
|
-
value: {
|
|
21
|
-
requestId: string;
|
|
22
|
-
responseCode: TransportError;
|
|
23
|
-
};
|
|
24
|
-
}>;
|
package/dist/structs.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Enum, Struct, Vector, enhanceCodec, str, u8 } from 'scale-ts';
|
|
2
|
-
export const TransportErrorCodec = enhanceCodec(u8, error => {
|
|
3
|
-
switch (error) {
|
|
4
|
-
case 'decryptionFailed':
|
|
5
|
-
return 1;
|
|
6
|
-
case 'decodingFailed':
|
|
7
|
-
return 2;
|
|
8
|
-
case 'unknown':
|
|
9
|
-
return 255;
|
|
10
|
-
}
|
|
11
|
-
}, code => {
|
|
12
|
-
switch (code) {
|
|
13
|
-
case 1:
|
|
14
|
-
return 'decryptionFailed';
|
|
15
|
-
case 2:
|
|
16
|
-
return 'decodingFailed';
|
|
17
|
-
default:
|
|
18
|
-
return 'unknown';
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
export const Request = (data) => {
|
|
22
|
-
return Struct({
|
|
23
|
-
requestId: str,
|
|
24
|
-
data: Vector(data),
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
export const Response = Struct({
|
|
28
|
-
requestId: str,
|
|
29
|
-
responseCode: TransportErrorCodec,
|
|
30
|
-
});
|
|
31
|
-
export const StatementData = (data) => {
|
|
32
|
-
return Enum({
|
|
33
|
-
request: Request(data),
|
|
34
|
-
response: Response,
|
|
35
|
-
});
|
|
36
|
-
};
|