@sirosfoundation/wmp-js 0.2.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.
@@ -0,0 +1,295 @@
1
+ /**
2
+ * WMP protocol types — mirrors go-wmp/pkg/wmp/types.go and methods.go.
3
+ */
4
+ export declare const VERSION = "0.1";
5
+ export interface Metadata {
6
+ version: string;
7
+ session_id?: string;
8
+ sender?: string;
9
+ timestamp?: string;
10
+ timestamp_token?: string;
11
+ expires_at?: string;
12
+ encrypted?: boolean;
13
+ epoch?: number;
14
+ signature?: string;
15
+ identity_assertions?: IdentityAssertion[];
16
+ relay_chain?: RelayEntry[];
17
+ trace_id?: string;
18
+ }
19
+ export interface IdentityAssertion {
20
+ type: string;
21
+ format?: string;
22
+ vp_token?: string;
23
+ audience?: string;
24
+ nonce?: string;
25
+ disclosed_claims?: string[];
26
+ x5c?: string[];
27
+ trust_hints?: TrustHint[];
28
+ }
29
+ export interface TrustHint {
30
+ framework: string;
31
+ lote_url?: string;
32
+ issuer_service_id?: string;
33
+ trust_anchor?: string;
34
+ entity_statement?: string;
35
+ root_ca?: string;
36
+ uri?: string;
37
+ validation_endpoint?: string;
38
+ }
39
+ export interface RelayEntry {
40
+ relay: string;
41
+ relay_id: string;
42
+ timestamp: string;
43
+ timestamp_token?: string;
44
+ signature?: string;
45
+ service_class?: string;
46
+ }
47
+ export interface SecurityMode {
48
+ mode: string;
49
+ min_tls_version?: string;
50
+ cipher_suites?: number[];
51
+ cipher_suite?: number;
52
+ mls_group_info?: string;
53
+ encrypted_capabilities?: string[];
54
+ }
55
+ export type Capabilities = Record<string, unknown>;
56
+ export declare const Method: {
57
+ readonly SessionCreate: "wmp.session.create";
58
+ readonly SessionResume: "wmp.session.resume";
59
+ readonly SessionClose: "wmp.session.close";
60
+ readonly SessionAuthenticate: "wmp.session.authenticate";
61
+ readonly MessageDeliver: "wmp.message.deliver";
62
+ readonly MessageAck: "wmp.message.ack";
63
+ readonly MessagePoll: "wmp.message.poll";
64
+ readonly MessageStatus: "wmp.message.status";
65
+ readonly CapabilityUpdate: "wmp.capability.update";
66
+ readonly CapabilityList: "wmp.capability.list";
67
+ readonly FlowStart: "wmp.flow.start";
68
+ readonly FlowProgress: "wmp.flow.progress";
69
+ readonly FlowAction: "wmp.flow.action";
70
+ readonly FlowComplete: "wmp.flow.complete";
71
+ readonly FlowError: "wmp.flow.error";
72
+ readonly FlowCancel: "wmp.flow.cancel";
73
+ readonly Resolve: "wmp.resolve";
74
+ readonly RelayRegister: "wmp.relay.register";
75
+ };
76
+ export type MethodName = (typeof Method)[keyof typeof Method];
77
+ export declare const ErrorCode: {
78
+ readonly ParseError: -32700;
79
+ readonly InvalidRequest: -32600;
80
+ readonly MethodNotFound: -32601;
81
+ readonly InvalidParams: -32602;
82
+ readonly InternalError: -32603;
83
+ readonly SessionNotFound: -31000;
84
+ readonly SessionExpired: -31001;
85
+ readonly NotAuthorized: -31002;
86
+ readonly EncryptionRequired: -31003;
87
+ readonly MLSError: -31004;
88
+ readonly CapabilityNotSupported: -31005;
89
+ readonly FlowError: -31006;
90
+ readonly RateLimited: -31007;
91
+ readonly ParticipantNotFound: -31008;
92
+ readonly EvidenceRequired: -31009;
93
+ readonly SignatureInvalid: -31010;
94
+ readonly TimestampInvalid: -31011;
95
+ readonly IdentityAssertionInvalid: -31012;
96
+ readonly VersionNotSupported: -31013;
97
+ readonly QueueFull: -31014;
98
+ };
99
+ export interface AuthObject {
100
+ type: string;
101
+ token?: string;
102
+ [key: string]: unknown;
103
+ }
104
+ export interface SessionCreateParams {
105
+ wmp: Metadata;
106
+ participants?: string[];
107
+ capabilities_offered?: Capabilities;
108
+ security: SecurityMode;
109
+ ttl?: number;
110
+ auth?: AuthObject;
111
+ }
112
+ export interface SessionCreateResult {
113
+ wmp: Metadata;
114
+ capabilities?: Capabilities;
115
+ security: SecurityMode;
116
+ challenge?: string;
117
+ }
118
+ export interface SessionResumeParams {
119
+ wmp: Metadata;
120
+ session_id: string;
121
+ last_message_id?: string;
122
+ }
123
+ export interface SessionCloseParams {
124
+ wmp: Metadata;
125
+ reason: string;
126
+ }
127
+ export interface SessionAuthenticateParams {
128
+ wmp: Metadata;
129
+ type: string;
130
+ token?: string;
131
+ response?: string;
132
+ [key: string]: unknown;
133
+ }
134
+ export interface SessionAuthenticateResult {
135
+ wmp: Metadata;
136
+ authenticated: boolean;
137
+ }
138
+ export declare const CloseReason: {
139
+ readonly Complete: "complete";
140
+ readonly Timeout: "timeout";
141
+ readonly Error: "error";
142
+ readonly UserCancelled: "user_cancelled";
143
+ };
144
+ export interface MessageDeliverParams {
145
+ wmp: Metadata;
146
+ to?: string[];
147
+ content_type?: string;
148
+ body?: unknown;
149
+ ciphertext?: string;
150
+ }
151
+ export interface MessageAckParams {
152
+ wmp: Metadata;
153
+ message_ids: string[];
154
+ status: string;
155
+ }
156
+ export interface MessagePollParams {
157
+ wmp: Metadata;
158
+ since?: string;
159
+ limit?: number;
160
+ }
161
+ export interface MessagePollResult {
162
+ wmp: Metadata;
163
+ messages: unknown[];
164
+ }
165
+ export interface MessageStatusParams {
166
+ wmp: Metadata;
167
+ message_id: string;
168
+ status: string;
169
+ reason?: string;
170
+ }
171
+ export declare const AckStatus: {
172
+ readonly Received: "received";
173
+ readonly Read: "read";
174
+ readonly Processed: "processed";
175
+ readonly Failed: "failed";
176
+ };
177
+ export interface CapabilityUpdateParams {
178
+ wmp: Metadata;
179
+ add?: Capabilities;
180
+ remove?: string[];
181
+ security?: SecurityMode;
182
+ }
183
+ export interface CapabilityUpdateResult {
184
+ wmp: Metadata;
185
+ capabilities: Capabilities;
186
+ security: SecurityMode;
187
+ }
188
+ export interface CapabilityListParams {
189
+ wmp: Metadata;
190
+ }
191
+ export interface CapabilityListResult {
192
+ wmp: Metadata;
193
+ capabilities: Capabilities;
194
+ security: SecurityMode;
195
+ }
196
+ export interface FlowStartParams {
197
+ wmp: Metadata;
198
+ flow_type: string;
199
+ flow_id: string;
200
+ params?: unknown;
201
+ timeout?: number;
202
+ }
203
+ export interface FlowStartResult {
204
+ wmp: Metadata;
205
+ flow_id: string;
206
+ flow_type: string;
207
+ }
208
+ export interface FlowProgressParams {
209
+ wmp: Metadata;
210
+ flow_id: string;
211
+ step: string;
212
+ payload?: unknown;
213
+ }
214
+ export interface FlowActionParams {
215
+ wmp: Metadata;
216
+ flow_id: string;
217
+ action: string;
218
+ params?: unknown;
219
+ }
220
+ export interface FlowActionResult {
221
+ wmp: Metadata;
222
+ flow_id: string;
223
+ action: string;
224
+ status: string;
225
+ }
226
+ export interface FlowCompleteParams {
227
+ wmp: Metadata;
228
+ flow_id: string;
229
+ result?: unknown;
230
+ }
231
+ export interface FlowErrorParams {
232
+ wmp: Metadata;
233
+ flow_id: string;
234
+ code: number;
235
+ message: string;
236
+ data?: unknown;
237
+ }
238
+ export interface FlowCancelParams {
239
+ wmp: Metadata;
240
+ flow_id: string;
241
+ reason?: string;
242
+ }
243
+ export interface FlowCancelResult {
244
+ wmp: Metadata;
245
+ flow_id: string;
246
+ status: string;
247
+ }
248
+ export declare const FlowType: {
249
+ readonly Approval: "approval";
250
+ readonly Sign: "sign";
251
+ readonly Message: "message";
252
+ };
253
+ export declare const CancelReason: {
254
+ readonly UserCancelled: "user_cancelled";
255
+ readonly Superseded: "superseded";
256
+ readonly NoLongerNeeded: "no_longer_needed";
257
+ };
258
+ export interface ResolveParams {
259
+ wmp: Metadata;
260
+ type: string;
261
+ uri: string;
262
+ options?: unknown;
263
+ }
264
+ export interface ResolveResult {
265
+ wmp: Metadata;
266
+ type: string;
267
+ uri: string;
268
+ metadata: unknown;
269
+ trust_info?: unknown;
270
+ }
271
+ export declare const ResolveType: {
272
+ readonly VCTM: "vctm";
273
+ readonly IssuerMetadata: "issuer_metadata";
274
+ readonly Trust: "trust";
275
+ readonly Endpoint: "endpoint";
276
+ readonly OpenIDFederation: "openid_federation";
277
+ };
278
+ export interface RelayRegisterParams {
279
+ wmp: Metadata;
280
+ auth?: AuthObject;
281
+ }
282
+ export interface RelayRegisterResult {
283
+ wmp: Metadata;
284
+ registered: boolean;
285
+ ttl?: number;
286
+ }
287
+ export interface RelayCap {
288
+ destinations?: string[];
289
+ }
290
+ export declare const ServiceClass: {
291
+ readonly BestEffort: "best_effort";
292
+ readonly Standard: "standard";
293
+ readonly Registered: "registered";
294
+ readonly Certified: "certified";
295
+ };
package/dist/types.js ADDED
@@ -0,0 +1,88 @@
1
+ /**
2
+ * WMP protocol types — mirrors go-wmp/pkg/wmp/types.go and methods.go.
3
+ */
4
+ export const VERSION = "0.1";
5
+ // ---------------------------------------------------------------------------
6
+ // Method constants
7
+ // ---------------------------------------------------------------------------
8
+ export const Method = {
9
+ SessionCreate: "wmp.session.create",
10
+ SessionResume: "wmp.session.resume",
11
+ SessionClose: "wmp.session.close",
12
+ SessionAuthenticate: "wmp.session.authenticate",
13
+ MessageDeliver: "wmp.message.deliver",
14
+ MessageAck: "wmp.message.ack",
15
+ MessagePoll: "wmp.message.poll",
16
+ MessageStatus: "wmp.message.status",
17
+ CapabilityUpdate: "wmp.capability.update",
18
+ CapabilityList: "wmp.capability.list",
19
+ FlowStart: "wmp.flow.start",
20
+ FlowProgress: "wmp.flow.progress",
21
+ FlowAction: "wmp.flow.action",
22
+ FlowComplete: "wmp.flow.complete",
23
+ FlowError: "wmp.flow.error",
24
+ FlowCancel: "wmp.flow.cancel",
25
+ Resolve: "wmp.resolve",
26
+ RelayRegister: "wmp.relay.register",
27
+ };
28
+ // ---------------------------------------------------------------------------
29
+ // Error codes
30
+ // ---------------------------------------------------------------------------
31
+ export const ErrorCode = {
32
+ ParseError: -32700,
33
+ InvalidRequest: -32600,
34
+ MethodNotFound: -32601,
35
+ InvalidParams: -32602,
36
+ InternalError: -32603,
37
+ SessionNotFound: -31000,
38
+ SessionExpired: -31001,
39
+ NotAuthorized: -31002,
40
+ EncryptionRequired: -31003,
41
+ MLSError: -31004,
42
+ CapabilityNotSupported: -31005,
43
+ FlowError: -31006,
44
+ RateLimited: -31007,
45
+ ParticipantNotFound: -31008,
46
+ EvidenceRequired: -31009,
47
+ SignatureInvalid: -31010,
48
+ TimestampInvalid: -31011,
49
+ IdentityAssertionInvalid: -31012,
50
+ VersionNotSupported: -31013,
51
+ QueueFull: -31014,
52
+ };
53
+ // Close reason constants.
54
+ export const CloseReason = {
55
+ Complete: "complete",
56
+ Timeout: "timeout",
57
+ Error: "error",
58
+ UserCancelled: "user_cancelled",
59
+ };
60
+ export const AckStatus = {
61
+ Received: "received",
62
+ Read: "read",
63
+ Processed: "processed",
64
+ Failed: "failed",
65
+ };
66
+ export const FlowType = {
67
+ Approval: "approval",
68
+ Sign: "sign",
69
+ Message: "message",
70
+ };
71
+ export const CancelReason = {
72
+ UserCancelled: "user_cancelled",
73
+ Superseded: "superseded",
74
+ NoLongerNeeded: "no_longer_needed",
75
+ };
76
+ export const ResolveType = {
77
+ VCTM: "vctm",
78
+ IssuerMetadata: "issuer_metadata",
79
+ Trust: "trust",
80
+ Endpoint: "endpoint",
81
+ OpenIDFederation: "openid_federation",
82
+ };
83
+ export const ServiceClass = {
84
+ BestEffort: "best_effort",
85
+ Standard: "standard",
86
+ Registered: "registered",
87
+ Certified: "certified",
88
+ };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@sirosfoundation/wmp-js",
3
+ "version": "0.2.0",
4
+ "description": "Wallet Messaging Protocol (WMP) client library — JSON-RPC 2.0 over WebSocket and HTTP+SSE",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./node": {
14
+ "import": "./dist/node.js",
15
+ "types": "./dist/node.d.ts"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
25
+ "lint": "tsc --noEmit"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^25.7.0",
29
+ "typescript": "^5.7.0",
30
+ "vitest": "^3.2.0"
31
+ },
32
+ "license": "BSD-2-Clause",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/sirosfoundation/wmp-js.git"
36
+ },
37
+ "dependencies": {
38
+ "ajv": "^8.20.0",
39
+ "ajv-formats": "^3.0.1"
40
+ }
41
+ }