@novasamatech/host-papp 0.5.0-9 → 0.5.0
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/dist/common-types.d.ts +8667 -0
- package/.papi/descriptors/dist/common.d.ts +1 -0
- package/.papi/descriptors/dist/descriptors-UUEW32EL.mjs +27 -0
- package/.papi/descriptors/dist/descriptors.d.ts +1 -0
- package/.papi/descriptors/dist/index.d.ts +10 -0
- package/.papi/descriptors/dist/index.js +237 -0
- package/.papi/descriptors/dist/index.mjs +148 -0
- package/.papi/descriptors/dist/metadataTypes-E4AQJDJR.mjs +6 -0
- package/.papi/descriptors/dist/metadataTypes.d.ts +2 -0
- package/.papi/descriptors/dist/people_lite.d.ts +7757 -0
- package/.papi/descriptors/dist/people_lite_metadata-EIVHV27X.mjs +6 -0
- package/.papi/descriptors/dist/people_lite_metadata.d.ts +2 -0
- package/.papi/descriptors/generated.json +1 -0
- package/.papi/descriptors/package.json +24 -0
- package/.papi/metadata/people_lite.scale +0 -0
- package/.papi/polkadot-api.json +15 -0
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +2 -2
- package/dist/crypto.d.ts +11 -5
- package/dist/crypto.js +47 -11
- package/dist/helpers/abortError.d.ts +0 -1
- package/dist/helpers/abortError.js +0 -3
- package/dist/identity/rpcAdapter.js +13 -5
- package/dist/identity/types.d.ts +3 -4
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -0
- package/dist/papp.js +3 -3
- package/dist/sso/auth/attestationService.d.ts +18 -0
- package/dist/sso/auth/attestationService.js +171 -0
- package/dist/sso/auth/impl.d.ts +36 -5
- package/dist/sso/auth/impl.js +94 -56
- package/dist/sso/auth/types.d.ts +15 -2
- package/dist/sso/sessionManager/scale/hex.d.ts +1 -0
- package/dist/sso/sessionManager/scale/hex.js +3 -0
- package/dist/sso/sessionManager/scale/remoteMessage.d.ts +30 -12
- package/dist/sso/sessionManager/scale/remoteMessage.js +10 -11
- package/dist/sso/sessionManager/scale/signPayloadRequest.d.ts +20 -0
- package/dist/sso/sessionManager/scale/signPayloadRequest.js +20 -0
- package/dist/sso/sessionManager/scale/signPayloadResponse.d.ts +14 -0
- package/dist/sso/sessionManager/scale/signPayloadResponse.js +10 -0
- package/dist/sso/sessionManager/userSession.d.ts +5 -7
- package/dist/sso/sessionManager/userSession.js +53 -12
- package/dist/sso/userSecretRepository.d.ts +1 -0
- package/dist/sso/userSecretRepository.js +2 -1
- package/dist/sso/userSessionRepository.js +0 -1
- package/package.json +12 -9
- 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/repository/ssoSessionRepository.d.ts +0 -22
- package/dist/sso/sessionManager/repository/ssoSessionRepository.js +0 -27
- 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,22 +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
|
-
type Params = {
|
|
11
|
-
storage: StorageAdapter;
|
|
12
|
-
};
|
|
13
|
-
export declare const createSsoSessionRepository: ({ storage }: Params) => {
|
|
14
|
-
add(value: UserSession): import("neverthrow").ResultAsync<UserSession, Error>;
|
|
15
|
-
filter(fn: (value: UserSession) => boolean): import("neverthrow").ResultAsync<UserSession[], Error>;
|
|
16
|
-
mutate(fn: (value: UserSession[]) => UserSession[]): import("neverthrow").ResultAsync<UserSession[], Error>;
|
|
17
|
-
read(): import("neverthrow").ResultAsync<UserSession[], Error>;
|
|
18
|
-
write(value: UserSession[]): import("neverthrow").ResultAsync<UserSession[], Error> | import("neverthrow").ResultAsync<null, Error>;
|
|
19
|
-
clear(): import("neverthrow").ResultAsync<void, Error>;
|
|
20
|
-
subscribe(fn: (value: UserSession[]) => void): VoidFunction;
|
|
21
|
-
};
|
|
22
|
-
export {};
|
|
@@ -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
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Encryption, StatementProver, StatementStoreAdapter } from '@novasamatech/statement-store';
|
|
2
|
-
import type { StorageAdapter } from '@novasamatech/storage-adapter';
|
|
3
|
-
import { ResultAsync } from 'neverthrow';
|
|
4
|
-
import type { CodecType } from 'scale-ts';
|
|
5
|
-
import type { Callback } from '../../types.js';
|
|
6
|
-
import type { UserSession } from '../ssoSessionRepository.js';
|
|
7
|
-
import { RemoteMessageCodec, RemoteMessageDataCodec } from './scale/remoteMessage.js';
|
|
8
|
-
export type SsoSession = ReturnType<typeof createSsoSession>;
|
|
9
|
-
export declare function createSsoSession({ userSession, statementStore, encryption, storage, prover, }: {
|
|
10
|
-
userSession: UserSession;
|
|
11
|
-
statementStore: StatementStoreAdapter;
|
|
12
|
-
encryption: Encryption;
|
|
13
|
-
storage: StorageAdapter;
|
|
14
|
-
prover: StatementProver;
|
|
15
|
-
}): {
|
|
16
|
-
request(message: CodecType<typeof RemoteMessageDataCodec>): ResultAsync<{
|
|
17
|
-
requestId: string;
|
|
18
|
-
}, Error>;
|
|
19
|
-
sendDisconnectMessage(): ResultAsync<{
|
|
20
|
-
requestId: string;
|
|
21
|
-
}, Error>;
|
|
22
|
-
subscribe(callback: Callback<CodecType<typeof RemoteMessageCodec>, ResultAsync<boolean, Error>>): VoidFunction;
|
|
23
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { createSession } from '@novasamatech/statement-store';
|
|
2
|
-
import { fieldListView } from '@novasamatech/storage-adapter';
|
|
3
|
-
import { nanoid } from 'nanoid';
|
|
4
|
-
import { ResultAsync, okAsync } from 'neverthrow';
|
|
5
|
-
import { RemoteMessageCodec, RemoteMessageDataCodec } from './scale/remoteMessage.js';
|
|
6
|
-
export function createSsoSession({ userSession, statementStore, encryption, storage, prover, }) {
|
|
7
|
-
const session = createSession({
|
|
8
|
-
localAccount: userSession.local,
|
|
9
|
-
remoteAccount: userSession.remote,
|
|
10
|
-
statementStore,
|
|
11
|
-
encryption,
|
|
12
|
-
prover,
|
|
13
|
-
});
|
|
14
|
-
const processedMessages = fieldListView({
|
|
15
|
-
storage,
|
|
16
|
-
key: `sso_processed_${userSession.id}`,
|
|
17
|
-
from: JSON.parse,
|
|
18
|
-
to: JSON.stringify,
|
|
19
|
-
initial: [],
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
request(message) {
|
|
23
|
-
return session.submitRequest(RemoteMessageCodec, {
|
|
24
|
-
messageId: nanoid(),
|
|
25
|
-
data: message,
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
sendDisconnectMessage() {
|
|
29
|
-
return session.submitRequest(RemoteMessageCodec, {
|
|
30
|
-
messageId: nanoid(),
|
|
31
|
-
data: {
|
|
32
|
-
tag: 'v1',
|
|
33
|
-
value: {
|
|
34
|
-
tag: 'Disconnected',
|
|
35
|
-
value: undefined,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
subscribe(callback) {
|
|
41
|
-
return session.subscribe(RemoteMessageCodec, messages => {
|
|
42
|
-
processedMessages.read().andThen(processed => {
|
|
43
|
-
const results = messages.map(message => {
|
|
44
|
-
if (message.type === 'request') {
|
|
45
|
-
const isMessageProcessed = processed.includes(message.data.messageId);
|
|
46
|
-
if (isMessageProcessed) {
|
|
47
|
-
return okAsync({ processed: false });
|
|
48
|
-
}
|
|
49
|
-
return callback(message.data)
|
|
50
|
-
.orTee(error => {
|
|
51
|
-
console.error('Error while processing sso messsage:', error);
|
|
52
|
-
})
|
|
53
|
-
.orElse(() => okAsync(false))
|
|
54
|
-
.map(processed => (processed ? { processed, message: message.data } : { processed }));
|
|
55
|
-
}
|
|
56
|
-
return okAsync({ processed: false });
|
|
57
|
-
});
|
|
58
|
-
return ResultAsync.combine(results).andThen(results => {
|
|
59
|
-
const newMessages = results.filter(x => x.processed).map(x => x.message.messageId);
|
|
60
|
-
if (newMessages.length > 0) {
|
|
61
|
-
return processedMessages.mutate(x => x.concat(newMessages));
|
|
62
|
-
}
|
|
63
|
-
return okAsync();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { StatementProver } from '@novasamatech/statement-store';
|
|
2
|
-
import type { UserSession } from '../ssoSessionRepository.js';
|
|
3
|
-
import type { UserSecretRepository } from '../userSecretRepository.js';
|
|
4
|
-
export declare function createSsoStatementProver(userSession: UserSession, userSecretRepository: UserSecretRepository): StatementProver;
|
|
@@ -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
|
-
};
|