@novasamatech/host-papp 0.8.7-5 → 0.8.8
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 +2 -2
- package/dist/sso/sessionManager/scale/createTransaction.d.ts +17 -0
- package/dist/sso/sessionManager/scale/createTransaction.js +6 -1
- package/dist/sso/sessionManager/scale/remoteMessage.d.ts +36 -0
- package/dist/sso/sessionManager/scale/remoteMessage.js +5 -2
- package/dist/sso/sessionManager/scale/signing.d.ts +16 -0
- package/dist/sso/sessionManager/scale/signing.js +13 -1
- package/dist/sso/sessionManager/userSession.d.ts +4 -2
- package/dist/sso/sessionManager/userSession.js +49 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export { AllowanceError } from './sso/allowance/index.js';
|
|
|
9
9
|
export type { UserSession } from './sso/sessionManager/userSession.js';
|
|
10
10
|
export type { StoredUserSession } from './sso/userSessionRepository.js';
|
|
11
11
|
export type { Identity } from './identity/types.js';
|
|
12
|
-
export type { SigningPayloadRequest, SigningPayloadResponse, SigningRawRequest, SigningRequest, } from './sso/sessionManager/scale/signing.js';
|
|
12
|
+
export type { SignRawLegacyRequest, SignRawLegacyResponse, SigningPayloadRequest, SigningPayloadResponse, SigningRawRequest, SigningRequest, } from './sso/sessionManager/scale/signing.js';
|
|
13
13
|
export type { RingVrfAliasRequest, RingVrfAliasResponse } from './sso/sessionManager/scale/ringVrf.js';
|
|
14
|
-
export type { CreateTransactionRequest, CreateTransactionResponse, } from './sso/sessionManager/scale/createTransaction.js';
|
|
14
|
+
export type { CreateTransactionLegacyRequest, CreateTransactionRequest, CreateTransactionResponse, } from './sso/sessionManager/scale/createTransaction.js';
|
|
@@ -16,6 +16,23 @@ export declare const CreateTransactionRequestCodec: import("scale-ts").Codec<{
|
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
}>;
|
|
19
|
+
export type CreateTransactionLegacyRequest = CodecType<typeof CreateTransactionLegacyRequestCodec>;
|
|
20
|
+
export declare const CreateTransactionLegacyRequestCodec: import("scale-ts").Codec<{
|
|
21
|
+
payload: {
|
|
22
|
+
tag: "v1";
|
|
23
|
+
value: {
|
|
24
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
25
|
+
genesisHash: Uint8Array<ArrayBufferLike>;
|
|
26
|
+
callData: Uint8Array<ArrayBufferLike>;
|
|
27
|
+
extensions: {
|
|
28
|
+
id: string;
|
|
29
|
+
extra: Uint8Array<ArrayBufferLike>;
|
|
30
|
+
additionalSigned: Uint8Array<ArrayBufferLike>;
|
|
31
|
+
}[];
|
|
32
|
+
txExtVersion: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
19
36
|
export type CreateTransactionResponse = CodecType<typeof CreateTransactionResponseCodec>;
|
|
20
37
|
export declare const CreateTransactionResponseCodec: import("scale-ts").Codec<{
|
|
21
38
|
respondingTo: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductAccountTransaction } from '@novasamatech/host-api';
|
|
1
|
+
import { LegacyTransaction, ProductAccountTransaction } from '@novasamatech/host-api';
|
|
2
2
|
import { Enum } from '@novasamatech/scale';
|
|
3
3
|
import { Bytes, Result, Struct, str } from 'scale-ts';
|
|
4
4
|
export const CreateTransactionRequestCodec = Struct({
|
|
@@ -6,6 +6,11 @@ export const CreateTransactionRequestCodec = Struct({
|
|
|
6
6
|
v1: ProductAccountTransaction,
|
|
7
7
|
}),
|
|
8
8
|
});
|
|
9
|
+
export const CreateTransactionLegacyRequestCodec = Struct({
|
|
10
|
+
payload: Enum({
|
|
11
|
+
v1: LegacyTransaction,
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
9
14
|
export const CreateTransactionResponseCodec = Struct({
|
|
10
15
|
// referencing to RemoteMessage.messageId
|
|
11
16
|
respondingTo: str,
|
|
@@ -143,6 +143,42 @@ export declare const RemoteMessageCodec: import("scale-ts").Codec<{
|
|
|
143
143
|
respondingTo: string;
|
|
144
144
|
signedTransaction: import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, string>;
|
|
145
145
|
};
|
|
146
|
+
} | {
|
|
147
|
+
tag: "CreateTransactionLegacyRequest";
|
|
148
|
+
value: {
|
|
149
|
+
payload: {
|
|
150
|
+
tag: "v1";
|
|
151
|
+
value: {
|
|
152
|
+
signer: Uint8Array<ArrayBufferLike>;
|
|
153
|
+
genesisHash: Uint8Array<ArrayBufferLike>;
|
|
154
|
+
callData: Uint8Array<ArrayBufferLike>;
|
|
155
|
+
extensions: {
|
|
156
|
+
id: string;
|
|
157
|
+
extra: Uint8Array<ArrayBufferLike>;
|
|
158
|
+
additionalSigned: Uint8Array<ArrayBufferLike>;
|
|
159
|
+
}[];
|
|
160
|
+
txExtVersion: number;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
} | {
|
|
165
|
+
tag: "SignRawLegacyRequest";
|
|
166
|
+
value: {
|
|
167
|
+
account: Uint8Array<ArrayBufferLike>;
|
|
168
|
+
data: {
|
|
169
|
+
tag: "Bytes";
|
|
170
|
+
value: Uint8Array<ArrayBufferLike>;
|
|
171
|
+
} | {
|
|
172
|
+
tag: "Payload";
|
|
173
|
+
value: string;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
} | {
|
|
177
|
+
tag: "SignRawLegacyResponse";
|
|
178
|
+
value: {
|
|
179
|
+
respondingTo: string;
|
|
180
|
+
signature: import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, string>;
|
|
181
|
+
};
|
|
146
182
|
};
|
|
147
183
|
};
|
|
148
184
|
}>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Enum, Struct, _void, str } from 'scale-ts';
|
|
2
|
-
import { CreateTransactionRequestCodec, CreateTransactionResponseCodec } from './createTransaction.js';
|
|
2
|
+
import { CreateTransactionLegacyRequestCodec, CreateTransactionRequestCodec, CreateTransactionResponseCodec, } from './createTransaction.js';
|
|
3
3
|
import { ResourceAllocationRequestCodec, ResourceAllocationResponseCodec } from './resourceAllocation.js';
|
|
4
4
|
import { RingVrfAliasRequestCodec, RingVrfAliasResponseCodec } from './ringVrf.js';
|
|
5
|
-
import { SigningRequestCodec, SigningResponseCodec } from './signing.js';
|
|
5
|
+
import { SignRawLegacyRequestCodec, SignRawLegacyResponseCodec, SigningRequestCodec, SigningResponseCodec, } from './signing.js';
|
|
6
6
|
export const RemoteMessageCodec = Struct({
|
|
7
7
|
messageId: str,
|
|
8
8
|
data: Enum({
|
|
@@ -16,6 +16,9 @@ export const RemoteMessageCodec = Struct({
|
|
|
16
16
|
ResourceAllocationResponse: ResourceAllocationResponseCodec,
|
|
17
17
|
CreateTransactionRequest: CreateTransactionRequestCodec,
|
|
18
18
|
CreateTransactionResponse: CreateTransactionResponseCodec,
|
|
19
|
+
CreateTransactionLegacyRequest: CreateTransactionLegacyRequestCodec,
|
|
20
|
+
SignRawLegacyRequest: SignRawLegacyRequestCodec,
|
|
21
|
+
SignRawLegacyResponse: SignRawLegacyResponseCodec,
|
|
19
22
|
}),
|
|
20
23
|
}),
|
|
21
24
|
});
|
|
@@ -29,6 +29,22 @@ export declare const SigningRawRequestCodec: import("scale-ts").Codec<{
|
|
|
29
29
|
value: string;
|
|
30
30
|
};
|
|
31
31
|
}>;
|
|
32
|
+
export type SignRawLegacyRequest = CodecType<typeof SignRawLegacyRequestCodec>;
|
|
33
|
+
export declare const SignRawLegacyRequestCodec: import("scale-ts").Codec<{
|
|
34
|
+
account: Uint8Array<ArrayBufferLike>;
|
|
35
|
+
data: {
|
|
36
|
+
tag: "Bytes";
|
|
37
|
+
value: Uint8Array<ArrayBufferLike>;
|
|
38
|
+
} | {
|
|
39
|
+
tag: "Payload";
|
|
40
|
+
value: string;
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
export type SignRawLegacyResponse = CodecType<typeof SignRawLegacyResponseCodec>;
|
|
44
|
+
export declare const SignRawLegacyResponseCodec: import("scale-ts").Codec<{
|
|
45
|
+
respondingTo: string;
|
|
46
|
+
signature: import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, string>;
|
|
47
|
+
}>;
|
|
32
48
|
export type SigningRequest = CodecType<typeof SigningRequestCodec>;
|
|
33
49
|
export declare const SigningRequestCodec: import("scale-ts").Codec<{
|
|
34
50
|
tag: "Payload";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductAccountId } from '@novasamatech/host-api';
|
|
1
|
+
import { AccountId, ProductAccountId } from '@novasamatech/host-api';
|
|
2
2
|
import { Enum, Hex, OptionBool } from '@novasamatech/scale';
|
|
3
3
|
import { Bytes, Option, Result, Struct, Vector, str, u32 } from 'scale-ts';
|
|
4
4
|
export const SigningPayloadRequestCodec = Struct({
|
|
@@ -26,6 +26,18 @@ export const SigningRawRequestCodec = Struct({
|
|
|
26
26
|
Payload: str,
|
|
27
27
|
}),
|
|
28
28
|
});
|
|
29
|
+
export const SignRawLegacyRequestCodec = Struct({
|
|
30
|
+
account: AccountId,
|
|
31
|
+
data: Enum({
|
|
32
|
+
Bytes: Bytes(),
|
|
33
|
+
Payload: str,
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
export const SignRawLegacyResponseCodec = Struct({
|
|
37
|
+
// referencing to RemoteMessage.messageId
|
|
38
|
+
respondingTo: str,
|
|
39
|
+
signature: Result(Bytes(), str),
|
|
40
|
+
});
|
|
29
41
|
export const SigningRequestCodec = Enum({
|
|
30
42
|
Payload: SigningPayloadRequestCodec,
|
|
31
43
|
Raw: SigningRawRequestCodec,
|
|
@@ -5,16 +5,18 @@ import { ResultAsync } from 'neverthrow';
|
|
|
5
5
|
import type { CodecType } from 'scale-ts';
|
|
6
6
|
import type { Callback } from '../../types.js';
|
|
7
7
|
import type { StoredUserSession } from '../userSessionRepository.js';
|
|
8
|
-
import type { CreateTransactionRequest } from './scale/createTransaction.js';
|
|
8
|
+
import type { CreateTransactionLegacyRequest, CreateTransactionRequest } from './scale/createTransaction.js';
|
|
9
9
|
import { RemoteMessageCodec } from './scale/remoteMessage.js';
|
|
10
10
|
import type { ApAllocationOutcome, ResourceAllocationRequest } from './scale/resourceAllocation.js';
|
|
11
|
-
import type { SigningPayloadRequest, SigningPayloadResponseData, SigningRawRequest } from './scale/signing.js';
|
|
11
|
+
import type { SignRawLegacyRequest, SigningPayloadRequest, SigningPayloadResponseData, SigningRawRequest } from './scale/signing.js';
|
|
12
12
|
export type UserSession = StoredUserSession & {
|
|
13
13
|
sendDisconnectMessage(): ResultAsync<void, Error>;
|
|
14
14
|
abortPendingRequests(): ResultAsync<void, Error>;
|
|
15
15
|
signPayload(payload: SigningPayloadRequest): ResultAsync<SigningPayloadResponseData, Error>;
|
|
16
16
|
signRaw(payload: SigningRawRequest): ResultAsync<SigningPayloadResponseData, Error>;
|
|
17
|
+
signRawLegacy(payload: SignRawLegacyRequest): ResultAsync<Uint8Array, Error>;
|
|
17
18
|
createTransaction(payload: CreateTransactionRequest): ResultAsync<Uint8Array, Error>;
|
|
19
|
+
createTransactionLegacy(payload: CreateTransactionLegacyRequest): ResultAsync<Uint8Array, Error>;
|
|
18
20
|
getRingVrfAlias(productAccountId: CodecType<typeof ProductAccountId>, productId: string): ResultAsync<CodecType<typeof ContextualAlias>, Error>;
|
|
19
21
|
requestResourceAllocation(request: ResourceAllocationRequest): ResultAsync<ApAllocationOutcome[], Error>;
|
|
20
22
|
subscribe(callback: Callback<CodecType<typeof RemoteMessageCodec>, ResultAsync<boolean, Error>>): VoidFunction;
|
|
@@ -162,6 +162,31 @@ export function createUserSession({ userSession, statementStore, encryption, sto
|
|
|
162
162
|
return withHostActionTrace(withQueueTimeout(inner, 'signRaw'), messageId, userSession.id);
|
|
163
163
|
});
|
|
164
164
|
},
|
|
165
|
+
signRawLegacy(payload) {
|
|
166
|
+
return enqueue(() => {
|
|
167
|
+
const messageId = nanoid();
|
|
168
|
+
const data = enumValue('v1', enumValue('SignRawLegacyRequest', payload));
|
|
169
|
+
emitHostAction(messageId, actionKindFromMessageData(data), userSession.id);
|
|
170
|
+
const responseFilter = (message) => {
|
|
171
|
+
if (message.data.tag === 'v1' &&
|
|
172
|
+
message.data.value.tag === 'SignRawLegacyResponse' &&
|
|
173
|
+
message.data.value.value.respondingTo === messageId) {
|
|
174
|
+
return message.data.value.value.signature;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const request = session.request(RemoteMessageCodec, { messageId, data });
|
|
178
|
+
const reply = session.waitForRequestMessage(RemoteMessageCodec, responseFilter);
|
|
179
|
+
const inner = awaitReplyOrAckFailure(request, reply).andThen(message => {
|
|
180
|
+
if (message.success) {
|
|
181
|
+
return ok(message.value);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return err(new Error(message.value));
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
return withHostActionTrace(withQueueTimeout(inner, 'signRawLegacy'), messageId, userSession.id);
|
|
188
|
+
});
|
|
189
|
+
},
|
|
165
190
|
createTransaction(payload) {
|
|
166
191
|
return enqueue(() => {
|
|
167
192
|
const messageId = nanoid();
|
|
@@ -186,6 +211,30 @@ export function createUserSession({ userSession, statementStore, encryption, sto
|
|
|
186
211
|
return withQueueTimeout(inner, 'createTransaction');
|
|
187
212
|
});
|
|
188
213
|
},
|
|
214
|
+
createTransactionLegacy(payload) {
|
|
215
|
+
return enqueue(() => {
|
|
216
|
+
const messageId = nanoid();
|
|
217
|
+
const data = enumValue('v1', enumValue('CreateTransactionLegacyRequest', payload));
|
|
218
|
+
const responseFilter = (message) => {
|
|
219
|
+
if (message.data.tag === 'v1' &&
|
|
220
|
+
message.data.value.tag === 'CreateTransactionResponse' &&
|
|
221
|
+
message.data.value.value.respondingTo === messageId) {
|
|
222
|
+
return message.data.value.value.signedTransaction;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const request = session.request(RemoteMessageCodec, { messageId, data });
|
|
226
|
+
const reply = session.waitForRequestMessage(RemoteMessageCodec, responseFilter);
|
|
227
|
+
const inner = awaitReplyOrAckFailure(request, reply).andThen(message => {
|
|
228
|
+
if (message.success) {
|
|
229
|
+
return ok(message.value);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
return err(new Error(message.value));
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
return withQueueTimeout(inner, 'createTransactionLegacy');
|
|
236
|
+
});
|
|
237
|
+
},
|
|
189
238
|
getRingVrfAlias(productAccountId, productId) {
|
|
190
239
|
return enqueue(() => {
|
|
191
240
|
const messageId = nanoid();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-papp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.8",
|
|
5
5
|
"description": "Polkadot app integration",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"@noble/ciphers": "2.2.0",
|
|
35
35
|
"@noble/curves": "2.2.0",
|
|
36
36
|
"@noble/hashes": "2.2.0",
|
|
37
|
-
"@novasamatech/host-api": "0.8.
|
|
38
|
-
"@novasamatech/scale": "0.8.
|
|
39
|
-
"@novasamatech/statement-store": "0.8.
|
|
40
|
-
"@novasamatech/storage-adapter": "0.8.
|
|
37
|
+
"@novasamatech/host-api": "0.8.8",
|
|
38
|
+
"@novasamatech/scale": "0.8.8",
|
|
39
|
+
"@novasamatech/statement-store": "0.8.8",
|
|
40
|
+
"@novasamatech/storage-adapter": "0.8.8",
|
|
41
41
|
"@polkadot-api/utils": "^0.4.0",
|
|
42
42
|
"@polkadot-labs/hdkd-helpers": "^0.0.30",
|
|
43
43
|
"nanoevents": "9.1.0",
|