@novasamatech/host-papp 0.7.8-2 → 0.7.9-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/dist/index.d.ts +1 -2
- package/dist/sso/sessionManager/scale/createTransaction.d.ts +22 -0
- package/dist/sso/sessionManager/scale/createTransaction.js +13 -0
- package/dist/sso/sessionManager/scale/remoteMessage.d.ts +23 -0
- package/dist/sso/sessionManager/scale/remoteMessage.js +4 -2
- package/dist/sso/sessionManager/scale/signing.d.ts +78 -0
- package/dist/sso/sessionManager/scale/signing.js +41 -0
- package/dist/sso/sessionManager/userSession.d.ts +3 -2
- package/dist/sso/sessionManager/userSession.js +27 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,5 @@ export type { AttestationStatus, PairingStatus } from './sso/auth/types.js';
|
|
|
6
6
|
export type { UserSession } from './sso/sessionManager/userSession.js';
|
|
7
7
|
export type { StoredUserSession } from './sso/userSessionRepository.js';
|
|
8
8
|
export type { Identity } from './identity/types.js';
|
|
9
|
-
export type { SigningPayloadRequest, SigningRawRequest, SigningRequest, } from './sso/sessionManager/scale/
|
|
10
|
-
export type { SigningPayloadResponse } from './sso/sessionManager/scale/signingResponse.js';
|
|
9
|
+
export type { SigningPayloadRequest, SigningPayloadResponse, SigningRawRequest, SigningRequest, } from './sso/sessionManager/scale/signing.js';
|
|
11
10
|
export type { RingVrfAliasRequest, RingVrfAliasResponse } from './sso/sessionManager/scale/ringVrf.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CodecType } from 'scale-ts';
|
|
2
|
+
export type CreateTransactionRequest = CodecType<typeof CreateTransactionRequestCodec>;
|
|
3
|
+
export declare const CreateTransactionRequestCodec: import("scale-ts").Codec<{
|
|
4
|
+
payload: {
|
|
5
|
+
tag: "v1";
|
|
6
|
+
value: {
|
|
7
|
+
signer: [string, number];
|
|
8
|
+
callData: Uint8Array<ArrayBufferLike>;
|
|
9
|
+
extensions: {
|
|
10
|
+
id: string;
|
|
11
|
+
extra: Uint8Array<ArrayBufferLike>;
|
|
12
|
+
additionalSigned: Uint8Array<ArrayBufferLike>;
|
|
13
|
+
}[];
|
|
14
|
+
txExtVersion: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
export type CreateTransactionResponse = CodecType<typeof CreateTransactionResponseCodec>;
|
|
19
|
+
export declare const CreateTransactionResponseCodec: import("scale-ts").Codec<{
|
|
20
|
+
respondingTo: string;
|
|
21
|
+
signedTransaction: import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, string>;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ProductAccountTransaction } from '@novasamatech/host-api';
|
|
2
|
+
import { Enum } from '@novasamatech/scale';
|
|
3
|
+
import { Bytes, Result, Struct, str } from 'scale-ts';
|
|
4
|
+
export const CreateTransactionRequestCodec = Struct({
|
|
5
|
+
payload: Enum({
|
|
6
|
+
v1: ProductAccountTransaction,
|
|
7
|
+
}),
|
|
8
|
+
});
|
|
9
|
+
export const CreateTransactionResponseCodec = Struct({
|
|
10
|
+
// referencing to RemoteMessage.messageId
|
|
11
|
+
respondingTo: str,
|
|
12
|
+
signedTransaction: Result(Bytes(), str),
|
|
13
|
+
});
|
|
@@ -119,6 +119,29 @@ export declare const RemoteMessageCodec: import("scale-ts").Codec<{
|
|
|
119
119
|
value: undefined;
|
|
120
120
|
})[], string>;
|
|
121
121
|
};
|
|
122
|
+
} | {
|
|
123
|
+
tag: "CreateTransactionRequest";
|
|
124
|
+
value: {
|
|
125
|
+
payload: {
|
|
126
|
+
tag: "v1";
|
|
127
|
+
value: {
|
|
128
|
+
signer: [string, number];
|
|
129
|
+
callData: Uint8Array<ArrayBufferLike>;
|
|
130
|
+
extensions: {
|
|
131
|
+
id: string;
|
|
132
|
+
extra: Uint8Array<ArrayBufferLike>;
|
|
133
|
+
additionalSigned: Uint8Array<ArrayBufferLike>;
|
|
134
|
+
}[];
|
|
135
|
+
txExtVersion: number;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
} | {
|
|
140
|
+
tag: "CreateTransactionResponse";
|
|
141
|
+
value: {
|
|
142
|
+
respondingTo: string;
|
|
143
|
+
signedTransaction: import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, string>;
|
|
144
|
+
};
|
|
122
145
|
};
|
|
123
146
|
};
|
|
124
147
|
}>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Enum, Struct, _void, str } from 'scale-ts';
|
|
2
|
+
import { CreateTransactionRequestCodec, CreateTransactionResponseCodec } from './createTransaction.js';
|
|
2
3
|
import { ResourceAllocationRequestCodec, ResourceAllocationResponseCodec } from './resourceAllocation.js';
|
|
3
4
|
import { RingVrfAliasRequestCodec, RingVrfAliasResponseCodec } from './ringVrf.js';
|
|
4
|
-
import { SigningRequestCodec } from './
|
|
5
|
-
import { SigningResponseCodec } from './signingResponse.js';
|
|
5
|
+
import { SigningRequestCodec, SigningResponseCodec } from './signing.js';
|
|
6
6
|
export const RemoteMessageCodec = Struct({
|
|
7
7
|
messageId: str,
|
|
8
8
|
data: Enum({
|
|
@@ -14,6 +14,8 @@ export const RemoteMessageCodec = Struct({
|
|
|
14
14
|
RingVrfAliasResponse: RingVrfAliasResponseCodec,
|
|
15
15
|
ResourceAllocationRequest: ResourceAllocationRequestCodec,
|
|
16
16
|
ResourceAllocationResponse: ResourceAllocationResponseCodec,
|
|
17
|
+
CreateTransactionRequest: CreateTransactionRequestCodec,
|
|
18
|
+
CreateTransactionResponse: CreateTransactionResponseCodec,
|
|
17
19
|
}),
|
|
18
20
|
}),
|
|
19
21
|
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { CodecType } from 'scale-ts';
|
|
2
|
+
export type SigningPayloadRequest = CodecType<typeof SigningPayloadRequestCodec>;
|
|
3
|
+
export declare const SigningPayloadRequestCodec: import("scale-ts").Codec<{
|
|
4
|
+
productAccountId: [string, number];
|
|
5
|
+
blockHash: `0x${string}`;
|
|
6
|
+
blockNumber: `0x${string}`;
|
|
7
|
+
era: `0x${string}`;
|
|
8
|
+
genesisHash: `0x${string}`;
|
|
9
|
+
method: `0x${string}`;
|
|
10
|
+
nonce: `0x${string}`;
|
|
11
|
+
specVersion: `0x${string}`;
|
|
12
|
+
tip: `0x${string}`;
|
|
13
|
+
transactionVersion: `0x${string}`;
|
|
14
|
+
signedExtensions: string[];
|
|
15
|
+
version: number;
|
|
16
|
+
assetId: `0x${string}` | undefined;
|
|
17
|
+
metadataHash: `0x${string}` | undefined;
|
|
18
|
+
mode: number | undefined;
|
|
19
|
+
withSignedTransaction: boolean | void;
|
|
20
|
+
}>;
|
|
21
|
+
export type SigningRawRequest = CodecType<typeof SigningRawRequestCodec>;
|
|
22
|
+
export declare const SigningRawRequestCodec: import("scale-ts").Codec<{
|
|
23
|
+
productAccountId: [string, number];
|
|
24
|
+
data: {
|
|
25
|
+
tag: "Bytes";
|
|
26
|
+
value: Uint8Array<ArrayBufferLike>;
|
|
27
|
+
} | {
|
|
28
|
+
tag: "Payload";
|
|
29
|
+
value: string;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
export type SigningRequest = CodecType<typeof SigningRequestCodec>;
|
|
33
|
+
export declare const SigningRequestCodec: import("scale-ts").Codec<{
|
|
34
|
+
tag: "Payload";
|
|
35
|
+
value: {
|
|
36
|
+
productAccountId: [string, number];
|
|
37
|
+
blockHash: `0x${string}`;
|
|
38
|
+
blockNumber: `0x${string}`;
|
|
39
|
+
era: `0x${string}`;
|
|
40
|
+
genesisHash: `0x${string}`;
|
|
41
|
+
method: `0x${string}`;
|
|
42
|
+
nonce: `0x${string}`;
|
|
43
|
+
specVersion: `0x${string}`;
|
|
44
|
+
tip: `0x${string}`;
|
|
45
|
+
transactionVersion: `0x${string}`;
|
|
46
|
+
signedExtensions: string[];
|
|
47
|
+
version: number;
|
|
48
|
+
assetId: `0x${string}` | undefined;
|
|
49
|
+
metadataHash: `0x${string}` | undefined;
|
|
50
|
+
mode: number | undefined;
|
|
51
|
+
withSignedTransaction: boolean | void;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
tag: "Raw";
|
|
55
|
+
value: {
|
|
56
|
+
productAccountId: [string, number];
|
|
57
|
+
data: {
|
|
58
|
+
tag: "Bytes";
|
|
59
|
+
value: Uint8Array<ArrayBufferLike>;
|
|
60
|
+
} | {
|
|
61
|
+
tag: "Payload";
|
|
62
|
+
value: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}>;
|
|
66
|
+
export type SigningPayloadResponseData = CodecType<typeof SigningPayloadResponseDataCodec>;
|
|
67
|
+
export declare const SigningPayloadResponseDataCodec: import("scale-ts").Codec<{
|
|
68
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
69
|
+
signedTransaction: Uint8Array<ArrayBufferLike> | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
export type SigningPayloadResponse = CodecType<typeof SigningResponseCodec>;
|
|
72
|
+
export declare const SigningResponseCodec: import("scale-ts").Codec<{
|
|
73
|
+
respondingTo: string;
|
|
74
|
+
payload: import("scale-ts").ResultPayload<{
|
|
75
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
76
|
+
signedTransaction: Uint8Array<ArrayBufferLike> | undefined;
|
|
77
|
+
}, string>;
|
|
78
|
+
}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ProductAccountId } from '@novasamatech/host-api';
|
|
2
|
+
import { Enum, Hex, OptionBool } from '@novasamatech/scale';
|
|
3
|
+
import { Bytes, Option, Result, Struct, Vector, str, u32 } from 'scale-ts';
|
|
4
|
+
export const SigningPayloadRequestCodec = Struct({
|
|
5
|
+
productAccountId: ProductAccountId,
|
|
6
|
+
blockHash: Hex(),
|
|
7
|
+
blockNumber: Hex(),
|
|
8
|
+
era: Hex(),
|
|
9
|
+
genesisHash: Hex(),
|
|
10
|
+
method: Hex(),
|
|
11
|
+
nonce: Hex(),
|
|
12
|
+
specVersion: Hex(),
|
|
13
|
+
tip: Hex(),
|
|
14
|
+
transactionVersion: Hex(),
|
|
15
|
+
signedExtensions: Vector(str),
|
|
16
|
+
version: u32,
|
|
17
|
+
assetId: Option(Hex()),
|
|
18
|
+
metadataHash: Option(Hex()),
|
|
19
|
+
mode: Option(u32),
|
|
20
|
+
withSignedTransaction: OptionBool,
|
|
21
|
+
});
|
|
22
|
+
export const SigningRawRequestCodec = Struct({
|
|
23
|
+
productAccountId: ProductAccountId,
|
|
24
|
+
data: Enum({
|
|
25
|
+
Bytes: Bytes(),
|
|
26
|
+
Payload: str,
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
export const SigningRequestCodec = Enum({
|
|
30
|
+
Payload: SigningPayloadRequestCodec,
|
|
31
|
+
Raw: SigningRawRequestCodec,
|
|
32
|
+
});
|
|
33
|
+
export const SigningPayloadResponseDataCodec = Struct({
|
|
34
|
+
signature: Bytes(),
|
|
35
|
+
signedTransaction: Option(Bytes()),
|
|
36
|
+
});
|
|
37
|
+
export const SigningResponseCodec = Struct({
|
|
38
|
+
// referencing to RemoteMessage.messageId
|
|
39
|
+
respondingTo: str,
|
|
40
|
+
payload: Result(SigningPayloadResponseDataCodec, str),
|
|
41
|
+
});
|
|
@@ -5,14 +5,15 @@ 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
9
|
import { RemoteMessageCodec } from './scale/remoteMessage.js';
|
|
9
10
|
import type { ApAllocationOutcome, ResourceAllocationRequest } from './scale/resourceAllocation.js';
|
|
10
|
-
import type { SigningPayloadRequest, SigningRawRequest } from './scale/
|
|
11
|
-
import type { SigningPayloadResponseData } from './scale/signingResponse.js';
|
|
11
|
+
import type { SigningPayloadRequest, SigningPayloadResponseData, SigningRawRequest } from './scale/signing.js';
|
|
12
12
|
export type UserSession = StoredUserSession & {
|
|
13
13
|
sendDisconnectMessage(): ResultAsync<void, Error>;
|
|
14
14
|
signPayload(payload: SigningPayloadRequest): ResultAsync<SigningPayloadResponseData, Error>;
|
|
15
15
|
signRaw(payload: SigningRawRequest): ResultAsync<SigningPayloadResponseData, Error>;
|
|
16
|
+
createTransaction(payload: CreateTransactionRequest): ResultAsync<Uint8Array, Error>;
|
|
16
17
|
getRingVrfAlias(productAccountId: CodecType<typeof ProductAccountId>, productId: string): ResultAsync<CodecType<typeof ContextualAlias>, Error>;
|
|
17
18
|
requestResourceAllocation(request: ResourceAllocationRequest): ResultAsync<ApAllocationOutcome[], Error>;
|
|
18
19
|
subscribe(callback: Callback<CodecType<typeof RemoteMessageCodec>, ResultAsync<boolean, Error>>): VoidFunction;
|
|
@@ -90,6 +90,33 @@ export function createUserSession({ userSession, statementStore, encryption, sto
|
|
|
90
90
|
return withQueueTimeout(inner, 'signRaw');
|
|
91
91
|
});
|
|
92
92
|
},
|
|
93
|
+
createTransaction(payload) {
|
|
94
|
+
return requestQueue.call(() => {
|
|
95
|
+
const messageId = nanoid();
|
|
96
|
+
const request = session.request(RemoteMessageCodec, {
|
|
97
|
+
messageId,
|
|
98
|
+
data: enumValue('v1', enumValue('CreateTransactionRequest', payload)),
|
|
99
|
+
});
|
|
100
|
+
const responseFilter = (message) => {
|
|
101
|
+
if (message.data.tag === 'v1' &&
|
|
102
|
+
message.data.value.tag === 'CreateTransactionResponse' &&
|
|
103
|
+
message.data.value.value.respondingTo === messageId) {
|
|
104
|
+
return message.data.value.value.signedTransaction;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const inner = request
|
|
108
|
+
.andThen(() => session.waitForRequestMessage(RemoteMessageCodec, responseFilter))
|
|
109
|
+
.andThen(message => {
|
|
110
|
+
if (message.success) {
|
|
111
|
+
return ok(message.value);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return err(new Error(message.value));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return withQueueTimeout(inner, 'createTransaction');
|
|
118
|
+
});
|
|
119
|
+
},
|
|
93
120
|
sendDisconnectMessage() {
|
|
94
121
|
return requestQueue.call(() => session
|
|
95
122
|
.submitRequestMessage(RemoteMessageCodec, {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-papp",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.9-0",
|
|
5
5
|
"description": "Polkadot app integration",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@noble/ciphers": "2.2.0",
|
|
30
30
|
"@noble/curves": "2.2.0",
|
|
31
31
|
"@noble/hashes": "2.2.0",
|
|
32
|
-
"@novasamatech/host-api": "0.7.
|
|
33
|
-
"@novasamatech/scale": "0.7.
|
|
34
|
-
"@novasamatech/statement-store": "0.7.
|
|
35
|
-
"@novasamatech/storage-adapter": "0.7.
|
|
32
|
+
"@novasamatech/host-api": "0.7.9-0",
|
|
33
|
+
"@novasamatech/scale": "0.7.9-0",
|
|
34
|
+
"@novasamatech/statement-store": "0.7.9-0",
|
|
35
|
+
"@novasamatech/storage-adapter": "0.7.9-0",
|
|
36
36
|
"@polkadot-labs/hdkd-helpers": "^0.0.30",
|
|
37
37
|
"nanoevents": "9.1.0",
|
|
38
38
|
"nanoid": "5.1.9",
|