@triveria/wallet 0.0.308 → 0.0.313
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/api.d.ts +143 -23
- package/api.js +201 -19
- package/client.d.ts +7 -0
- package/client.js +9 -0
- package/notifications.d.ts +83 -0
- package/notifications.js +284 -0
- package/package.json +5 -1
package/api.d.ts
CHANGED
|
@@ -660,6 +660,10 @@ export interface InitPreAuthOffer {
|
|
|
660
660
|
'issuerId': string;
|
|
661
661
|
'offerEndpoint'?: string;
|
|
662
662
|
'deferred'?: boolean;
|
|
663
|
+
/**
|
|
664
|
+
* ID of an WMP entity with which a WMP connection has already been established. If provided, WMP is used to send the credential offer to the specified recipient.
|
|
665
|
+
*/
|
|
666
|
+
'wmpEntityId'?: string;
|
|
663
667
|
}
|
|
664
668
|
export interface InputDescriptorSuitableCredentials {
|
|
665
669
|
/**
|
|
@@ -1087,6 +1091,10 @@ export interface VpInvalidNotification {
|
|
|
1087
1091
|
}
|
|
1088
1092
|
export interface VpPresentedNotification {
|
|
1089
1093
|
'credentialIds': Array<string>;
|
|
1094
|
+
/**
|
|
1095
|
+
* True when the presentation was submitted automatically, without user consent, because every requested credential was configured for auto-presentation.
|
|
1096
|
+
*/
|
|
1097
|
+
'autoAccepted'?: boolean;
|
|
1090
1098
|
}
|
|
1091
1099
|
export interface VpVerifiedNotification {
|
|
1092
1100
|
'verifierId': string;
|
|
@@ -1260,15 +1268,17 @@ export declare const WmpAuthenticateSessionTypeEnum: {
|
|
|
1260
1268
|
export type WmpAuthenticateSessionTypeEnum = typeof WmpAuthenticateSessionTypeEnum[keyof typeof WmpAuthenticateSessionTypeEnum];
|
|
1261
1269
|
/**
|
|
1262
1270
|
* @type WmpClientRequestBody
|
|
1263
|
-
* Action to take on a pending WMP client request, discriminated by `type`: `
|
|
1271
|
+
* Action to take on a pending WMP client request, discriminated by `type`: `process_offer` a pending credential offer, `process_verification_request` a pending verification request, `identity_assertion` to present a credential, or `authenticate` to open the session.
|
|
1264
1272
|
*/
|
|
1265
1273
|
export type WmpClientRequestBody = {
|
|
1266
1274
|
type: 'authenticate';
|
|
1267
1275
|
} & WmpAuthenticateSession | {
|
|
1268
1276
|
type: 'identity_assertion';
|
|
1269
1277
|
} & WmpProvideIdentityAssertion | {
|
|
1270
|
-
type: '
|
|
1271
|
-
} &
|
|
1278
|
+
type: 'process_offer';
|
|
1279
|
+
} & WmpProcessOfferRequest | {
|
|
1280
|
+
type: 'process_verification_request';
|
|
1281
|
+
} & WmpProcessVerificationRequest;
|
|
1272
1282
|
export interface WmpCreateInvitationResponse {
|
|
1273
1283
|
/**
|
|
1274
1284
|
* URL at which the invitation can be downloaded
|
|
@@ -1317,24 +1327,54 @@ export interface WmpEntityRecord {
|
|
|
1317
1327
|
'verified': boolean;
|
|
1318
1328
|
'identifiers': Array<WmpEntityKeyIdentifier>;
|
|
1319
1329
|
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Metadata for a received WMP message. The body is downloaded as raw bytes from the link this object carries (`bodyUrl`).
|
|
1332
|
+
*/
|
|
1333
|
+
export interface WmpMessage {
|
|
1334
|
+
/**
|
|
1335
|
+
* Message ID.
|
|
1336
|
+
*/
|
|
1337
|
+
'id': string;
|
|
1338
|
+
/**
|
|
1339
|
+
* Sender identifier of the peer that delivered the message.
|
|
1340
|
+
*/
|
|
1341
|
+
'from': string;
|
|
1342
|
+
/**
|
|
1343
|
+
* Content type of the primary body.
|
|
1344
|
+
*/
|
|
1345
|
+
'contentType': string;
|
|
1346
|
+
/**
|
|
1347
|
+
* Download link for the raw message body.
|
|
1348
|
+
*/
|
|
1349
|
+
'bodyUrl': string;
|
|
1350
|
+
}
|
|
1320
1351
|
export interface WmpNotification {
|
|
1321
|
-
'
|
|
1322
|
-
'client'?: WmpEntityRecord;
|
|
1352
|
+
'entity'?: WmpEntityRecord;
|
|
1323
1353
|
'invitationUrl'?: string;
|
|
1324
1354
|
'id': string;
|
|
1325
1355
|
'error'?: string;
|
|
1326
1356
|
'identityAssertion'?: CredentialWrapper;
|
|
1327
1357
|
}
|
|
1328
1358
|
/**
|
|
1329
|
-
* Process a pending credential offer
|
|
1359
|
+
* Process a pending credential offer identified by the path id.
|
|
1360
|
+
*/
|
|
1361
|
+
export interface WmpProcessOfferRequest {
|
|
1362
|
+
'type': WmpProcessOfferRequestTypeEnum;
|
|
1363
|
+
}
|
|
1364
|
+
export declare const WmpProcessOfferRequestTypeEnum: {
|
|
1365
|
+
readonly ProcessOffer: "process_offer";
|
|
1366
|
+
};
|
|
1367
|
+
export type WmpProcessOfferRequestTypeEnum = typeof WmpProcessOfferRequestTypeEnum[keyof typeof WmpProcessOfferRequestTypeEnum];
|
|
1368
|
+
/**
|
|
1369
|
+
* Process a pending verification request identified by the path id.
|
|
1330
1370
|
*/
|
|
1331
|
-
export interface
|
|
1332
|
-
'type':
|
|
1371
|
+
export interface WmpProcessVerificationRequest {
|
|
1372
|
+
'type': WmpProcessVerificationRequestTypeEnum;
|
|
1333
1373
|
}
|
|
1334
|
-
export declare const
|
|
1335
|
-
readonly
|
|
1374
|
+
export declare const WmpProcessVerificationRequestTypeEnum: {
|
|
1375
|
+
readonly ProcessVerificationRequest: "process_verification_request";
|
|
1336
1376
|
};
|
|
1337
|
-
export type
|
|
1377
|
+
export type WmpProcessVerificationRequestTypeEnum = typeof WmpProcessVerificationRequestTypeEnum[keyof typeof WmpProcessVerificationRequestTypeEnum];
|
|
1338
1378
|
/**
|
|
1339
1379
|
* Provide a credential to present as the identity assertion for the session.
|
|
1340
1380
|
*/
|
|
@@ -1816,12 +1856,15 @@ export declare const DefaultApiAxiosParamCreator: (configuration?: Configuration
|
|
|
1816
1856
|
*/
|
|
1817
1857
|
walletNotificationHistory: (walletId: string, limit?: number, nextMarker?: string, type?: Array<WalletNotificationEventType>, sort?: ListSort, newerThan?: number, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
1818
1858
|
/**
|
|
1819
|
-
* Provides
|
|
1859
|
+
* Provides SSE stream of notifications for a specific wallet. Supports replay of queued notifications via `Last-Event-Id` header parameter.
|
|
1820
1860
|
* @param {string} walletId Wallet ID
|
|
1861
|
+
* @param {string} [eventType] Event type
|
|
1862
|
+
* @param {string} [state] Event state
|
|
1863
|
+
* @param {string} [lastEventID] SSE last event ID
|
|
1821
1864
|
* @param {*} [options] Override http request option.
|
|
1822
1865
|
* @throws {RequiredError}
|
|
1823
1866
|
*/
|
|
1824
|
-
walletNotifications: (walletId: string, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
1867
|
+
walletNotifications: (walletId: string, eventType?: string, state?: string, lastEventID?: string, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
1825
1868
|
/**
|
|
1826
1869
|
* Update wallet metadata and configuration.
|
|
1827
1870
|
* @param {string} walletId
|
|
@@ -1898,7 +1941,15 @@ export declare const DefaultApiAxiosParamCreator: (configuration?: Configuration
|
|
|
1898
1941
|
*/
|
|
1899
1942
|
wmpClientGetPendingRequests: (walletId: string, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
1900
1943
|
/**
|
|
1901
|
-
*
|
|
1944
|
+
* Returns metadata for the received message identified by `request_id` (delivered via a `wmp.message` notification carrying its id): its content type and body download link. The body is fetched as raw bytes from the download link included in the response (`bodyUrl`).
|
|
1945
|
+
* @param {string} walletId
|
|
1946
|
+
* @param {string} requestId
|
|
1947
|
+
* @param {*} [options] Override http request option.
|
|
1948
|
+
* @throws {RequiredError}
|
|
1949
|
+
*/
|
|
1950
|
+
wmpClientGetRequest: (walletId: string, requestId: string, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
1951
|
+
/**
|
|
1952
|
+
* Acts on a pending WMP client request identified by `request_id`. The body\'s `type` selects the action: `process_offer` a pending credential offer or `process_verification_request` a pending verification request (either returns its authorization requirements), `identity_assertion` to present a credential as the session identity assertion, or `authenticate` to open the session after the assertion exchange.
|
|
1902
1953
|
* @param {string} walletId
|
|
1903
1954
|
* @param {string} requestId
|
|
1904
1955
|
* @param {WmpClientRequestBody} wmpClientRequestBody
|
|
@@ -1945,6 +1996,15 @@ export declare const DefaultApiAxiosParamCreator: (configuration?: Configuration
|
|
|
1945
1996
|
* @throws {RequiredError}
|
|
1946
1997
|
*/
|
|
1947
1998
|
wmpEntityList: (walletId: string, entityType: WmpEntityListEntityTypeEnum, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
1999
|
+
/**
|
|
2000
|
+
* Sends a free-form WMP message to a connected entity. The session is auto-resumed if its transport has dropped. The peer receives it as a `wmp.message` notification and can then read the message metadata from `GET /wmp/client/requests/{request_id}` and download its body via the download link it contains. The request is `multipart/form-data`. Supply the primary body as either the `body` text field (plain text) or a `body` file part (any content type, taken from the part).
|
|
2001
|
+
* @param {string} walletId
|
|
2002
|
+
* @param {string} entityId
|
|
2003
|
+
* @param {File} [body] The primary message body: a plain-text form value, or a file part whose Content-Type becomes the message content type.
|
|
2004
|
+
* @param {*} [options] Override http request option.
|
|
2005
|
+
* @throws {RequiredError}
|
|
2006
|
+
*/
|
|
2007
|
+
wmpEntitySendMessage: (walletId: string, entityId: string, body?: File, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
1948
2008
|
/**
|
|
1949
2009
|
* Re-establishes or confirms the WebSocket connection to a WMP server entity. Used to reconnect after a dropped connection so the wallet can resume receiving pending requests.
|
|
1950
2010
|
* @param {string} walletId
|
|
@@ -2409,12 +2469,15 @@ export declare const DefaultApiFp: (configuration?: Configuration) => {
|
|
|
2409
2469
|
*/
|
|
2410
2470
|
walletNotificationHistory(walletId: string, limit?: number, nextMarker?: string, type?: Array<WalletNotificationEventType>, sort?: ListSort, newerThan?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<WalletNotificationHistory>>;
|
|
2411
2471
|
/**
|
|
2412
|
-
* Provides
|
|
2472
|
+
* Provides SSE stream of notifications for a specific wallet. Supports replay of queued notifications via `Last-Event-Id` header parameter.
|
|
2413
2473
|
* @param {string} walletId Wallet ID
|
|
2474
|
+
* @param {string} [eventType] Event type
|
|
2475
|
+
* @param {string} [state] Event state
|
|
2476
|
+
* @param {string} [lastEventID] SSE last event ID
|
|
2414
2477
|
* @param {*} [options] Override http request option.
|
|
2415
2478
|
* @throws {RequiredError}
|
|
2416
2479
|
*/
|
|
2417
|
-
walletNotifications(walletId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<
|
|
2480
|
+
walletNotifications(walletId: string, eventType?: string, state?: string, lastEventID?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<File>>;
|
|
2418
2481
|
/**
|
|
2419
2482
|
* Update wallet metadata and configuration.
|
|
2420
2483
|
* @param {string} walletId
|
|
@@ -2491,7 +2554,15 @@ export declare const DefaultApiFp: (configuration?: Configuration) => {
|
|
|
2491
2554
|
*/
|
|
2492
2555
|
wmpClientGetPendingRequests(walletId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<WmpRequest>>>;
|
|
2493
2556
|
/**
|
|
2494
|
-
*
|
|
2557
|
+
* Returns metadata for the received message identified by `request_id` (delivered via a `wmp.message` notification carrying its id): its content type and body download link. The body is fetched as raw bytes from the download link included in the response (`bodyUrl`).
|
|
2558
|
+
* @param {string} walletId
|
|
2559
|
+
* @param {string} requestId
|
|
2560
|
+
* @param {*} [options] Override http request option.
|
|
2561
|
+
* @throws {RequiredError}
|
|
2562
|
+
*/
|
|
2563
|
+
wmpClientGetRequest(walletId: string, requestId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<WmpMessage>>;
|
|
2564
|
+
/**
|
|
2565
|
+
* Acts on a pending WMP client request identified by `request_id`. The body\'s `type` selects the action: `process_offer` a pending credential offer or `process_verification_request` a pending verification request (either returns its authorization requirements), `identity_assertion` to present a credential as the session identity assertion, or `authenticate` to open the session after the assertion exchange.
|
|
2495
2566
|
* @param {string} walletId
|
|
2496
2567
|
* @param {string} requestId
|
|
2497
2568
|
* @param {WmpClientRequestBody} wmpClientRequestBody
|
|
@@ -2538,6 +2609,15 @@ export declare const DefaultApiFp: (configuration?: Configuration) => {
|
|
|
2538
2609
|
* @throws {RequiredError}
|
|
2539
2610
|
*/
|
|
2540
2611
|
wmpEntityList(walletId: string, entityType: WmpEntityListEntityTypeEnum, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<WmpEntityRecord>>>;
|
|
2612
|
+
/**
|
|
2613
|
+
* Sends a free-form WMP message to a connected entity. The session is auto-resumed if its transport has dropped. The peer receives it as a `wmp.message` notification and can then read the message metadata from `GET /wmp/client/requests/{request_id}` and download its body via the download link it contains. The request is `multipart/form-data`. Supply the primary body as either the `body` text field (plain text) or a `body` file part (any content type, taken from the part).
|
|
2614
|
+
* @param {string} walletId
|
|
2615
|
+
* @param {string} entityId
|
|
2616
|
+
* @param {File} [body] The primary message body: a plain-text form value, or a file part whose Content-Type becomes the message content type.
|
|
2617
|
+
* @param {*} [options] Override http request option.
|
|
2618
|
+
* @throws {RequiredError}
|
|
2619
|
+
*/
|
|
2620
|
+
wmpEntitySendMessage(walletId: string, entityId: string, body?: File, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>>;
|
|
2541
2621
|
/**
|
|
2542
2622
|
* Re-establishes or confirms the WebSocket connection to a WMP server entity. Used to reconnect after a dropped connection so the wallet can resume receiving pending requests.
|
|
2543
2623
|
* @param {string} walletId
|
|
@@ -3002,12 +3082,15 @@ export declare const DefaultApiFactory: (configuration?: Configuration, basePath
|
|
|
3002
3082
|
*/
|
|
3003
3083
|
walletNotificationHistory(walletId: string, limit?: number, nextMarker?: string, type?: Array<WalletNotificationEventType>, sort?: ListSort, newerThan?: number, options?: RawAxiosRequestConfig): AxiosPromise<WalletNotificationHistory>;
|
|
3004
3084
|
/**
|
|
3005
|
-
* Provides
|
|
3085
|
+
* Provides SSE stream of notifications for a specific wallet. Supports replay of queued notifications via `Last-Event-Id` header parameter.
|
|
3006
3086
|
* @param {string} walletId Wallet ID
|
|
3087
|
+
* @param {string} [eventType] Event type
|
|
3088
|
+
* @param {string} [state] Event state
|
|
3089
|
+
* @param {string} [lastEventID] SSE last event ID
|
|
3007
3090
|
* @param {*} [options] Override http request option.
|
|
3008
3091
|
* @throws {RequiredError}
|
|
3009
3092
|
*/
|
|
3010
|
-
walletNotifications(walletId: string, options?: RawAxiosRequestConfig): AxiosPromise<
|
|
3093
|
+
walletNotifications(walletId: string, eventType?: string, state?: string, lastEventID?: string, options?: RawAxiosRequestConfig): AxiosPromise<File>;
|
|
3011
3094
|
/**
|
|
3012
3095
|
* Update wallet metadata and configuration.
|
|
3013
3096
|
* @param {string} walletId
|
|
@@ -3084,7 +3167,15 @@ export declare const DefaultApiFactory: (configuration?: Configuration, basePath
|
|
|
3084
3167
|
*/
|
|
3085
3168
|
wmpClientGetPendingRequests(walletId: string, options?: RawAxiosRequestConfig): AxiosPromise<Array<WmpRequest>>;
|
|
3086
3169
|
/**
|
|
3087
|
-
*
|
|
3170
|
+
* Returns metadata for the received message identified by `request_id` (delivered via a `wmp.message` notification carrying its id): its content type and body download link. The body is fetched as raw bytes from the download link included in the response (`bodyUrl`).
|
|
3171
|
+
* @param {string} walletId
|
|
3172
|
+
* @param {string} requestId
|
|
3173
|
+
* @param {*} [options] Override http request option.
|
|
3174
|
+
* @throws {RequiredError}
|
|
3175
|
+
*/
|
|
3176
|
+
wmpClientGetRequest(walletId: string, requestId: string, options?: RawAxiosRequestConfig): AxiosPromise<WmpMessage>;
|
|
3177
|
+
/**
|
|
3178
|
+
* Acts on a pending WMP client request identified by `request_id`. The body\'s `type` selects the action: `process_offer` a pending credential offer or `process_verification_request` a pending verification request (either returns its authorization requirements), `identity_assertion` to present a credential as the session identity assertion, or `authenticate` to open the session after the assertion exchange.
|
|
3088
3179
|
* @param {string} walletId
|
|
3089
3180
|
* @param {string} requestId
|
|
3090
3181
|
* @param {WmpClientRequestBody} wmpClientRequestBody
|
|
@@ -3131,6 +3222,15 @@ export declare const DefaultApiFactory: (configuration?: Configuration, basePath
|
|
|
3131
3222
|
* @throws {RequiredError}
|
|
3132
3223
|
*/
|
|
3133
3224
|
wmpEntityList(walletId: string, entityType: WmpEntityListEntityTypeEnum, options?: RawAxiosRequestConfig): AxiosPromise<Array<WmpEntityRecord>>;
|
|
3225
|
+
/**
|
|
3226
|
+
* Sends a free-form WMP message to a connected entity. The session is auto-resumed if its transport has dropped. The peer receives it as a `wmp.message` notification and can then read the message metadata from `GET /wmp/client/requests/{request_id}` and download its body via the download link it contains. The request is `multipart/form-data`. Supply the primary body as either the `body` text field (plain text) or a `body` file part (any content type, taken from the part).
|
|
3227
|
+
* @param {string} walletId
|
|
3228
|
+
* @param {string} entityId
|
|
3229
|
+
* @param {File} [body] The primary message body: a plain-text form value, or a file part whose Content-Type becomes the message content type.
|
|
3230
|
+
* @param {*} [options] Override http request option.
|
|
3231
|
+
* @throws {RequiredError}
|
|
3232
|
+
*/
|
|
3233
|
+
wmpEntitySendMessage(walletId: string, entityId: string, body?: File, options?: RawAxiosRequestConfig): AxiosPromise<void>;
|
|
3134
3234
|
/**
|
|
3135
3235
|
* Re-establishes or confirms the WebSocket connection to a WMP server entity. Used to reconnect after a dropped connection so the wallet can resume receiving pending requests.
|
|
3136
3236
|
* @param {string} walletId
|
|
@@ -3595,12 +3695,15 @@ export declare class DefaultApi extends BaseAPI {
|
|
|
3595
3695
|
*/
|
|
3596
3696
|
walletNotificationHistory(walletId: string, limit?: number, nextMarker?: string, type?: Array<WalletNotificationEventType>, sort?: ListSort, newerThan?: number, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<WalletNotificationHistory, any, {}>>;
|
|
3597
3697
|
/**
|
|
3598
|
-
* Provides
|
|
3698
|
+
* Provides SSE stream of notifications for a specific wallet. Supports replay of queued notifications via `Last-Event-Id` header parameter.
|
|
3599
3699
|
* @param {string} walletId Wallet ID
|
|
3700
|
+
* @param {string} [eventType] Event type
|
|
3701
|
+
* @param {string} [state] Event state
|
|
3702
|
+
* @param {string} [lastEventID] SSE last event ID
|
|
3600
3703
|
* @param {*} [options] Override http request option.
|
|
3601
3704
|
* @throws {RequiredError}
|
|
3602
3705
|
*/
|
|
3603
|
-
walletNotifications(walletId: string, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<
|
|
3706
|
+
walletNotifications(walletId: string, eventType?: string, state?: string, lastEventID?: string, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<File, any, {}>>;
|
|
3604
3707
|
/**
|
|
3605
3708
|
* Update wallet metadata and configuration.
|
|
3606
3709
|
* @param {string} walletId
|
|
@@ -3677,7 +3780,15 @@ export declare class DefaultApi extends BaseAPI {
|
|
|
3677
3780
|
*/
|
|
3678
3781
|
wmpClientGetPendingRequests(walletId: string, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<WmpRequest[], any, {}>>;
|
|
3679
3782
|
/**
|
|
3680
|
-
*
|
|
3783
|
+
* Returns metadata for the received message identified by `request_id` (delivered via a `wmp.message` notification carrying its id): its content type and body download link. The body is fetched as raw bytes from the download link included in the response (`bodyUrl`).
|
|
3784
|
+
* @param {string} walletId
|
|
3785
|
+
* @param {string} requestId
|
|
3786
|
+
* @param {*} [options] Override http request option.
|
|
3787
|
+
* @throws {RequiredError}
|
|
3788
|
+
*/
|
|
3789
|
+
wmpClientGetRequest(walletId: string, requestId: string, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<WmpMessage, any, {}>>;
|
|
3790
|
+
/**
|
|
3791
|
+
* Acts on a pending WMP client request identified by `request_id`. The body\'s `type` selects the action: `process_offer` a pending credential offer or `process_verification_request` a pending verification request (either returns its authorization requirements), `identity_assertion` to present a credential as the session identity assertion, or `authenticate` to open the session after the assertion exchange.
|
|
3681
3792
|
* @param {string} walletId
|
|
3682
3793
|
* @param {string} requestId
|
|
3683
3794
|
* @param {WmpClientRequestBody} wmpClientRequestBody
|
|
@@ -3724,6 +3835,15 @@ export declare class DefaultApi extends BaseAPI {
|
|
|
3724
3835
|
* @throws {RequiredError}
|
|
3725
3836
|
*/
|
|
3726
3837
|
wmpEntityList(walletId: string, entityType: WmpEntityListEntityTypeEnum, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<WmpEntityRecord[], any, {}>>;
|
|
3838
|
+
/**
|
|
3839
|
+
* Sends a free-form WMP message to a connected entity. The session is auto-resumed if its transport has dropped. The peer receives it as a `wmp.message` notification and can then read the message metadata from `GET /wmp/client/requests/{request_id}` and download its body via the download link it contains. The request is `multipart/form-data`. Supply the primary body as either the `body` text field (plain text) or a `body` file part (any content type, taken from the part).
|
|
3840
|
+
* @param {string} walletId
|
|
3841
|
+
* @param {string} entityId
|
|
3842
|
+
* @param {File} [body] The primary message body: a plain-text form value, or a file part whose Content-Type becomes the message content type.
|
|
3843
|
+
* @param {*} [options] Override http request option.
|
|
3844
|
+
* @throws {RequiredError}
|
|
3845
|
+
*/
|
|
3846
|
+
wmpEntitySendMessage(walletId: string, entityId: string, body?: File, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any, {}>>;
|
|
3727
3847
|
/**
|
|
3728
3848
|
* Re-establishes or confirms the WebSocket connection to a WMP server entity. Used to reconnect after a dropped connection so the wallet can resume receiving pending requests.
|
|
3729
3849
|
* @param {string} walletId
|
package/api.js
CHANGED
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.WmpEntityListEntityTypeEnum = exports.CredentialListInteractionEnum = exports.DefaultApi = exports.DefaultApiFactory = exports.DefaultApiFp = exports.DefaultApiAxiosParamCreator = exports.XadesSignatureType = exports.WmpRequestType = exports.WmpProvideIdentityAssertionTypeEnum = exports.
|
|
28
|
+
exports.WmpEntityListEntityTypeEnum = exports.CredentialListInteractionEnum = exports.DefaultApi = exports.DefaultApiFactory = exports.DefaultApiFp = exports.DefaultApiAxiosParamCreator = exports.XadesSignatureType = exports.WmpRequestType = exports.WmpProvideIdentityAssertionTypeEnum = exports.WmpProcessVerificationRequestTypeEnum = exports.WmpProcessOfferRequestTypeEnum = exports.WmpAuthenticateSessionTypeEnum = exports.WalletNotificationEventType = exports.WalletCapability = exports.TrustListKind = exports.TrustFrameworkType = exports.SystemImpactStatusEnum = exports.SigningKeyIdentifier = exports.RevokeAccreditationRequestTypeEnum = exports.PresentationDefinitionSubmissionRequirementsRuleEnum = exports.OidcRevisionOidc4vpEnum = exports.OidcRevisionOidc4vciEnum = exports.ObjectVerticalAlignment = exports.ObjectHorizontalAlignment = exports.ListSort = exports.InteractionAuthorizationRequirementsRequirementTypeEnum = exports.HealthStatusStatusEnum = exports.EntityAccreditationRequestTypeEnum = exports.DocumentSignatureValidityVerificationResultEnum = exports.DeferredStatusEnum = exports.CredentialPropertyToVerify = exports.CredentialNotificationEventTypeEnum = exports.CredentialMetadataStatusEnum = exports.CredentialMetadataInteractionEnum = exports.CredentialIssuerDefinitionAuthorizationEnum = exports.CredentialIssuerDefinitionCredentialIssuerEnum = exports.CredentialFormat = exports.CertificateStatus = exports.AccreditationRequestTypeEnum = void 0;
|
|
29
29
|
const axios_1 = __importDefault(require("axios"));
|
|
30
30
|
// Some imports not used depending on template conditions
|
|
31
31
|
// @ts-ignore
|
|
@@ -211,8 +211,11 @@ exports.WalletNotificationEventType = {
|
|
|
211
211
|
exports.WmpAuthenticateSessionTypeEnum = {
|
|
212
212
|
Authenticate: 'authenticate',
|
|
213
213
|
};
|
|
214
|
-
exports.
|
|
215
|
-
|
|
214
|
+
exports.WmpProcessOfferRequestTypeEnum = {
|
|
215
|
+
ProcessOffer: 'process_offer',
|
|
216
|
+
};
|
|
217
|
+
exports.WmpProcessVerificationRequestTypeEnum = {
|
|
218
|
+
ProcessVerificationRequest: 'process_verification_request',
|
|
216
219
|
};
|
|
217
220
|
exports.WmpProvideIdentityAssertionTypeEnum = {
|
|
218
221
|
IdentityAssertion: 'identity_assertion',
|
|
@@ -2317,12 +2320,15 @@ const DefaultApiAxiosParamCreator = function (configuration) {
|
|
|
2317
2320
|
};
|
|
2318
2321
|
}),
|
|
2319
2322
|
/**
|
|
2320
|
-
* Provides
|
|
2323
|
+
* Provides SSE stream of notifications for a specific wallet. Supports replay of queued notifications via `Last-Event-Id` header parameter.
|
|
2321
2324
|
* @param {string} walletId Wallet ID
|
|
2325
|
+
* @param {string} [eventType] Event type
|
|
2326
|
+
* @param {string} [state] Event state
|
|
2327
|
+
* @param {string} [lastEventID] SSE last event ID
|
|
2322
2328
|
* @param {*} [options] Override http request option.
|
|
2323
2329
|
* @throws {RequiredError}
|
|
2324
2330
|
*/
|
|
2325
|
-
walletNotifications: (walletId_1, ...args_1) => __awaiter(this, [walletId_1, ...args_1], void 0, function* (walletId, options = {}) {
|
|
2331
|
+
walletNotifications: (walletId_1, eventType_1, state_1, lastEventID_1, ...args_1) => __awaiter(this, [walletId_1, eventType_1, state_1, lastEventID_1, ...args_1], void 0, function* (walletId, eventType, state, lastEventID, options = {}) {
|
|
2326
2332
|
// verify required parameter 'walletId' is not null or undefined
|
|
2327
2333
|
(0, common_1.assertParamExists)('walletNotifications', 'walletId', walletId);
|
|
2328
2334
|
const localVarPath = `/wallets/{wallet_id}/notifications`
|
|
@@ -2339,7 +2345,16 @@ const DefaultApiAxiosParamCreator = function (configuration) {
|
|
|
2339
2345
|
// authentication accessToken required
|
|
2340
2346
|
// http bearer authentication required
|
|
2341
2347
|
yield (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
|
|
2342
|
-
|
|
2348
|
+
if (eventType !== undefined) {
|
|
2349
|
+
localVarQueryParameter['eventType'] = eventType;
|
|
2350
|
+
}
|
|
2351
|
+
if (state !== undefined) {
|
|
2352
|
+
localVarQueryParameter['state'] = state;
|
|
2353
|
+
}
|
|
2354
|
+
localVarHeaderParameter['Accept'] = 'text/event-stream,application/json';
|
|
2355
|
+
if (lastEventID != null) {
|
|
2356
|
+
localVarHeaderParameter['Last-Event-ID'] = String(lastEventID);
|
|
2357
|
+
}
|
|
2343
2358
|
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
2344
2359
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
2345
2360
|
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
|
|
@@ -2685,7 +2700,45 @@ const DefaultApiAxiosParamCreator = function (configuration) {
|
|
|
2685
2700
|
};
|
|
2686
2701
|
}),
|
|
2687
2702
|
/**
|
|
2688
|
-
*
|
|
2703
|
+
* Returns metadata for the received message identified by `request_id` (delivered via a `wmp.message` notification carrying its id): its content type and body download link. The body is fetched as raw bytes from the download link included in the response (`bodyUrl`).
|
|
2704
|
+
* @param {string} walletId
|
|
2705
|
+
* @param {string} requestId
|
|
2706
|
+
* @param {*} [options] Override http request option.
|
|
2707
|
+
* @throws {RequiredError}
|
|
2708
|
+
*/
|
|
2709
|
+
wmpClientGetRequest: (walletId_1, requestId_1, ...args_1) => __awaiter(this, [walletId_1, requestId_1, ...args_1], void 0, function* (walletId, requestId, options = {}) {
|
|
2710
|
+
// verify required parameter 'walletId' is not null or undefined
|
|
2711
|
+
(0, common_1.assertParamExists)('wmpClientGetRequest', 'walletId', walletId);
|
|
2712
|
+
// verify required parameter 'requestId' is not null or undefined
|
|
2713
|
+
(0, common_1.assertParamExists)('wmpClientGetRequest', 'requestId', requestId);
|
|
2714
|
+
const localVarPath = `/wmp/client/requests/{request_id}`
|
|
2715
|
+
.replace('{request_id}', encodeURIComponent(String(requestId)));
|
|
2716
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
2717
|
+
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
2718
|
+
let baseOptions;
|
|
2719
|
+
if (configuration) {
|
|
2720
|
+
baseOptions = configuration.baseOptions;
|
|
2721
|
+
}
|
|
2722
|
+
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
|
|
2723
|
+
const localVarHeaderParameter = {};
|
|
2724
|
+
const localVarQueryParameter = {};
|
|
2725
|
+
// authentication accessToken required
|
|
2726
|
+
// http bearer authentication required
|
|
2727
|
+
yield (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
|
|
2728
|
+
localVarHeaderParameter['Accept'] = 'application/json';
|
|
2729
|
+
if (walletId != null) {
|
|
2730
|
+
localVarHeaderParameter['wallet-id'] = String(walletId);
|
|
2731
|
+
}
|
|
2732
|
+
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
2733
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
2734
|
+
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
|
|
2735
|
+
return {
|
|
2736
|
+
url: (0, common_1.toPathString)(localVarUrlObj),
|
|
2737
|
+
options: localVarRequestOptions,
|
|
2738
|
+
};
|
|
2739
|
+
}),
|
|
2740
|
+
/**
|
|
2741
|
+
* Acts on a pending WMP client request identified by `request_id`. The body\'s `type` selects the action: `process_offer` a pending credential offer or `process_verification_request` a pending verification request (either returns its authorization requirements), `identity_assertion` to present a credential as the session identity assertion, or `authenticate` to open the session after the assertion exchange.
|
|
2689
2742
|
* @param {string} walletId
|
|
2690
2743
|
* @param {string} requestId
|
|
2691
2744
|
* @param {WmpClientRequestBody} wmpClientRequestBody
|
|
@@ -2915,6 +2968,51 @@ const DefaultApiAxiosParamCreator = function (configuration) {
|
|
|
2915
2968
|
options: localVarRequestOptions,
|
|
2916
2969
|
};
|
|
2917
2970
|
}),
|
|
2971
|
+
/**
|
|
2972
|
+
* Sends a free-form WMP message to a connected entity. The session is auto-resumed if its transport has dropped. The peer receives it as a `wmp.message` notification and can then read the message metadata from `GET /wmp/client/requests/{request_id}` and download its body via the download link it contains. The request is `multipart/form-data`. Supply the primary body as either the `body` text field (plain text) or a `body` file part (any content type, taken from the part).
|
|
2973
|
+
* @param {string} walletId
|
|
2974
|
+
* @param {string} entityId
|
|
2975
|
+
* @param {File} [body] The primary message body: a plain-text form value, or a file part whose Content-Type becomes the message content type.
|
|
2976
|
+
* @param {*} [options] Override http request option.
|
|
2977
|
+
* @throws {RequiredError}
|
|
2978
|
+
*/
|
|
2979
|
+
wmpEntitySendMessage: (walletId_1, entityId_1, body_1, ...args_1) => __awaiter(this, [walletId_1, entityId_1, body_1, ...args_1], void 0, function* (walletId, entityId, body, options = {}) {
|
|
2980
|
+
// verify required parameter 'walletId' is not null or undefined
|
|
2981
|
+
(0, common_1.assertParamExists)('wmpEntitySendMessage', 'walletId', walletId);
|
|
2982
|
+
// verify required parameter 'entityId' is not null or undefined
|
|
2983
|
+
(0, common_1.assertParamExists)('wmpEntitySendMessage', 'entityId', entityId);
|
|
2984
|
+
const localVarPath = `/wmp/entities/{entity_id}/messages`
|
|
2985
|
+
.replace('{entity_id}', encodeURIComponent(String(entityId)));
|
|
2986
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
2987
|
+
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
2988
|
+
let baseOptions;
|
|
2989
|
+
if (configuration) {
|
|
2990
|
+
baseOptions = configuration.baseOptions;
|
|
2991
|
+
}
|
|
2992
|
+
const localVarRequestOptions = Object.assign(Object.assign({ method: 'POST' }, baseOptions), options);
|
|
2993
|
+
const localVarHeaderParameter = {};
|
|
2994
|
+
const localVarQueryParameter = {};
|
|
2995
|
+
const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)();
|
|
2996
|
+
// authentication accessToken required
|
|
2997
|
+
// http bearer authentication required
|
|
2998
|
+
yield (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
|
|
2999
|
+
if (body !== undefined) {
|
|
3000
|
+
localVarFormParams.append('body', body);
|
|
3001
|
+
}
|
|
3002
|
+
localVarHeaderParameter['Content-Type'] = 'multipart/form-data';
|
|
3003
|
+
localVarHeaderParameter['Accept'] = 'application/json';
|
|
3004
|
+
if (walletId != null) {
|
|
3005
|
+
localVarHeaderParameter['wallet-id'] = String(walletId);
|
|
3006
|
+
}
|
|
3007
|
+
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
3008
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
3009
|
+
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
|
|
3010
|
+
localVarRequestOptions.data = localVarFormParams;
|
|
3011
|
+
return {
|
|
3012
|
+
url: (0, common_1.toPathString)(localVarUrlObj),
|
|
3013
|
+
options: localVarRequestOptions,
|
|
3014
|
+
};
|
|
3015
|
+
}),
|
|
2918
3016
|
/**
|
|
2919
3017
|
* Re-establishes or confirms the WebSocket connection to a WMP server entity. Used to reconnect after a dropped connection so the wallet can resume receiving pending requests.
|
|
2920
3018
|
* @param {string} walletId
|
|
@@ -3851,15 +3949,18 @@ const DefaultApiFp = function (configuration) {
|
|
|
3851
3949
|
});
|
|
3852
3950
|
},
|
|
3853
3951
|
/**
|
|
3854
|
-
* Provides
|
|
3952
|
+
* Provides SSE stream of notifications for a specific wallet. Supports replay of queued notifications via `Last-Event-Id` header parameter.
|
|
3855
3953
|
* @param {string} walletId Wallet ID
|
|
3954
|
+
* @param {string} [eventType] Event type
|
|
3955
|
+
* @param {string} [state] Event state
|
|
3956
|
+
* @param {string} [lastEventID] SSE last event ID
|
|
3856
3957
|
* @param {*} [options] Override http request option.
|
|
3857
3958
|
* @throws {RequiredError}
|
|
3858
3959
|
*/
|
|
3859
|
-
walletNotifications(walletId, options) {
|
|
3960
|
+
walletNotifications(walletId, eventType, state, lastEventID, options) {
|
|
3860
3961
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3861
3962
|
var _a, _b, _c;
|
|
3862
|
-
const localVarAxiosArgs = yield localVarAxiosParamCreator.walletNotifications(walletId, options);
|
|
3963
|
+
const localVarAxiosArgs = yield localVarAxiosParamCreator.walletNotifications(walletId, eventType, state, lastEventID, options);
|
|
3863
3964
|
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
|
|
3864
3965
|
const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['DefaultApi.walletNotifications']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
|
|
3865
3966
|
return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
|
@@ -4021,7 +4122,23 @@ const DefaultApiFp = function (configuration) {
|
|
|
4021
4122
|
});
|
|
4022
4123
|
},
|
|
4023
4124
|
/**
|
|
4024
|
-
*
|
|
4125
|
+
* Returns metadata for the received message identified by `request_id` (delivered via a `wmp.message` notification carrying its id): its content type and body download link. The body is fetched as raw bytes from the download link included in the response (`bodyUrl`).
|
|
4126
|
+
* @param {string} walletId
|
|
4127
|
+
* @param {string} requestId
|
|
4128
|
+
* @param {*} [options] Override http request option.
|
|
4129
|
+
* @throws {RequiredError}
|
|
4130
|
+
*/
|
|
4131
|
+
wmpClientGetRequest(walletId, requestId, options) {
|
|
4132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4133
|
+
var _a, _b, _c;
|
|
4134
|
+
const localVarAxiosArgs = yield localVarAxiosParamCreator.wmpClientGetRequest(walletId, requestId, options);
|
|
4135
|
+
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
|
|
4136
|
+
const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['DefaultApi.wmpClientGetRequest']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
|
|
4137
|
+
return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
|
4138
|
+
});
|
|
4139
|
+
},
|
|
4140
|
+
/**
|
|
4141
|
+
* Acts on a pending WMP client request identified by `request_id`. The body\'s `type` selects the action: `process_offer` a pending credential offer or `process_verification_request` a pending verification request (either returns its authorization requirements), `identity_assertion` to present a credential as the session identity assertion, or `authenticate` to open the session after the assertion exchange.
|
|
4025
4142
|
* @param {string} walletId
|
|
4026
4143
|
* @param {string} requestId
|
|
4027
4144
|
* @param {WmpClientRequestBody} wmpClientRequestBody
|
|
@@ -4116,6 +4233,23 @@ const DefaultApiFp = function (configuration) {
|
|
|
4116
4233
|
return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
|
4117
4234
|
});
|
|
4118
4235
|
},
|
|
4236
|
+
/**
|
|
4237
|
+
* Sends a free-form WMP message to a connected entity. The session is auto-resumed if its transport has dropped. The peer receives it as a `wmp.message` notification and can then read the message metadata from `GET /wmp/client/requests/{request_id}` and download its body via the download link it contains. The request is `multipart/form-data`. Supply the primary body as either the `body` text field (plain text) or a `body` file part (any content type, taken from the part).
|
|
4238
|
+
* @param {string} walletId
|
|
4239
|
+
* @param {string} entityId
|
|
4240
|
+
* @param {File} [body] The primary message body: a plain-text form value, or a file part whose Content-Type becomes the message content type.
|
|
4241
|
+
* @param {*} [options] Override http request option.
|
|
4242
|
+
* @throws {RequiredError}
|
|
4243
|
+
*/
|
|
4244
|
+
wmpEntitySendMessage(walletId, entityId, body, options) {
|
|
4245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4246
|
+
var _a, _b, _c;
|
|
4247
|
+
const localVarAxiosArgs = yield localVarAxiosParamCreator.wmpEntitySendMessage(walletId, entityId, body, options);
|
|
4248
|
+
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
|
|
4249
|
+
const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['DefaultApi.wmpEntitySendMessage']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
|
|
4250
|
+
return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
|
4251
|
+
});
|
|
4252
|
+
},
|
|
4119
4253
|
/**
|
|
4120
4254
|
* Re-establishes or confirms the WebSocket connection to a WMP server entity. Used to reconnect after a dropped connection so the wallet can resume receiving pending requests.
|
|
4121
4255
|
* @param {string} walletId
|
|
@@ -4700,13 +4834,16 @@ const DefaultApiFactory = function (configuration, basePath, axios) {
|
|
|
4700
4834
|
return localVarFp.walletNotificationHistory(walletId, limit, nextMarker, type, sort, newerThan, options).then((request) => request(axios, basePath));
|
|
4701
4835
|
},
|
|
4702
4836
|
/**
|
|
4703
|
-
* Provides
|
|
4837
|
+
* Provides SSE stream of notifications for a specific wallet. Supports replay of queued notifications via `Last-Event-Id` header parameter.
|
|
4704
4838
|
* @param {string} walletId Wallet ID
|
|
4839
|
+
* @param {string} [eventType] Event type
|
|
4840
|
+
* @param {string} [state] Event state
|
|
4841
|
+
* @param {string} [lastEventID] SSE last event ID
|
|
4705
4842
|
* @param {*} [options] Override http request option.
|
|
4706
4843
|
* @throws {RequiredError}
|
|
4707
4844
|
*/
|
|
4708
|
-
walletNotifications(walletId, options) {
|
|
4709
|
-
return localVarFp.walletNotifications(walletId, options).then((request) => request(axios, basePath));
|
|
4845
|
+
walletNotifications(walletId, eventType, state, lastEventID, options) {
|
|
4846
|
+
return localVarFp.walletNotifications(walletId, eventType, state, lastEventID, options).then((request) => request(axios, basePath));
|
|
4710
4847
|
},
|
|
4711
4848
|
/**
|
|
4712
4849
|
* Update wallet metadata and configuration.
|
|
@@ -4804,7 +4941,17 @@ const DefaultApiFactory = function (configuration, basePath, axios) {
|
|
|
4804
4941
|
return localVarFp.wmpClientGetPendingRequests(walletId, options).then((request) => request(axios, basePath));
|
|
4805
4942
|
},
|
|
4806
4943
|
/**
|
|
4807
|
-
*
|
|
4944
|
+
* Returns metadata for the received message identified by `request_id` (delivered via a `wmp.message` notification carrying its id): its content type and body download link. The body is fetched as raw bytes from the download link included in the response (`bodyUrl`).
|
|
4945
|
+
* @param {string} walletId
|
|
4946
|
+
* @param {string} requestId
|
|
4947
|
+
* @param {*} [options] Override http request option.
|
|
4948
|
+
* @throws {RequiredError}
|
|
4949
|
+
*/
|
|
4950
|
+
wmpClientGetRequest(walletId, requestId, options) {
|
|
4951
|
+
return localVarFp.wmpClientGetRequest(walletId, requestId, options).then((request) => request(axios, basePath));
|
|
4952
|
+
},
|
|
4953
|
+
/**
|
|
4954
|
+
* Acts on a pending WMP client request identified by `request_id`. The body\'s `type` selects the action: `process_offer` a pending credential offer or `process_verification_request` a pending verification request (either returns its authorization requirements), `identity_assertion` to present a credential as the session identity assertion, or `authenticate` to open the session after the assertion exchange.
|
|
4808
4955
|
* @param {string} walletId
|
|
4809
4956
|
* @param {string} requestId
|
|
4810
4957
|
* @param {WmpClientRequestBody} wmpClientRequestBody
|
|
@@ -4863,6 +5010,17 @@ const DefaultApiFactory = function (configuration, basePath, axios) {
|
|
|
4863
5010
|
wmpEntityList(walletId, entityType, options) {
|
|
4864
5011
|
return localVarFp.wmpEntityList(walletId, entityType, options).then((request) => request(axios, basePath));
|
|
4865
5012
|
},
|
|
5013
|
+
/**
|
|
5014
|
+
* Sends a free-form WMP message to a connected entity. The session is auto-resumed if its transport has dropped. The peer receives it as a `wmp.message` notification and can then read the message metadata from `GET /wmp/client/requests/{request_id}` and download its body via the download link it contains. The request is `multipart/form-data`. Supply the primary body as either the `body` text field (plain text) or a `body` file part (any content type, taken from the part).
|
|
5015
|
+
* @param {string} walletId
|
|
5016
|
+
* @param {string} entityId
|
|
5017
|
+
* @param {File} [body] The primary message body: a plain-text form value, or a file part whose Content-Type becomes the message content type.
|
|
5018
|
+
* @param {*} [options] Override http request option.
|
|
5019
|
+
* @throws {RequiredError}
|
|
5020
|
+
*/
|
|
5021
|
+
wmpEntitySendMessage(walletId, entityId, body, options) {
|
|
5022
|
+
return localVarFp.wmpEntitySendMessage(walletId, entityId, body, options).then((request) => request(axios, basePath));
|
|
5023
|
+
},
|
|
4866
5024
|
/**
|
|
4867
5025
|
* Re-establishes or confirms the WebSocket connection to a WMP server entity. Used to reconnect after a dropped connection so the wallet can resume receiving pending requests.
|
|
4868
5026
|
* @param {string} walletId
|
|
@@ -5439,13 +5597,16 @@ class DefaultApi extends base_1.BaseAPI {
|
|
|
5439
5597
|
return (0, exports.DefaultApiFp)(this.configuration).walletNotificationHistory(walletId, limit, nextMarker, type, sort, newerThan, options).then((request) => request(this.axios, this.basePath));
|
|
5440
5598
|
}
|
|
5441
5599
|
/**
|
|
5442
|
-
* Provides
|
|
5600
|
+
* Provides SSE stream of notifications for a specific wallet. Supports replay of queued notifications via `Last-Event-Id` header parameter.
|
|
5443
5601
|
* @param {string} walletId Wallet ID
|
|
5602
|
+
* @param {string} [eventType] Event type
|
|
5603
|
+
* @param {string} [state] Event state
|
|
5604
|
+
* @param {string} [lastEventID] SSE last event ID
|
|
5444
5605
|
* @param {*} [options] Override http request option.
|
|
5445
5606
|
* @throws {RequiredError}
|
|
5446
5607
|
*/
|
|
5447
|
-
walletNotifications(walletId, options) {
|
|
5448
|
-
return (0, exports.DefaultApiFp)(this.configuration).walletNotifications(walletId, options).then((request) => request(this.axios, this.basePath));
|
|
5608
|
+
walletNotifications(walletId, eventType, state, lastEventID, options) {
|
|
5609
|
+
return (0, exports.DefaultApiFp)(this.configuration).walletNotifications(walletId, eventType, state, lastEventID, options).then((request) => request(this.axios, this.basePath));
|
|
5449
5610
|
}
|
|
5450
5611
|
/**
|
|
5451
5612
|
* Update wallet metadata and configuration.
|
|
@@ -5543,7 +5704,17 @@ class DefaultApi extends base_1.BaseAPI {
|
|
|
5543
5704
|
return (0, exports.DefaultApiFp)(this.configuration).wmpClientGetPendingRequests(walletId, options).then((request) => request(this.axios, this.basePath));
|
|
5544
5705
|
}
|
|
5545
5706
|
/**
|
|
5546
|
-
*
|
|
5707
|
+
* Returns metadata for the received message identified by `request_id` (delivered via a `wmp.message` notification carrying its id): its content type and body download link. The body is fetched as raw bytes from the download link included in the response (`bodyUrl`).
|
|
5708
|
+
* @param {string} walletId
|
|
5709
|
+
* @param {string} requestId
|
|
5710
|
+
* @param {*} [options] Override http request option.
|
|
5711
|
+
* @throws {RequiredError}
|
|
5712
|
+
*/
|
|
5713
|
+
wmpClientGetRequest(walletId, requestId, options) {
|
|
5714
|
+
return (0, exports.DefaultApiFp)(this.configuration).wmpClientGetRequest(walletId, requestId, options).then((request) => request(this.axios, this.basePath));
|
|
5715
|
+
}
|
|
5716
|
+
/**
|
|
5717
|
+
* Acts on a pending WMP client request identified by `request_id`. The body\'s `type` selects the action: `process_offer` a pending credential offer or `process_verification_request` a pending verification request (either returns its authorization requirements), `identity_assertion` to present a credential as the session identity assertion, or `authenticate` to open the session after the assertion exchange.
|
|
5547
5718
|
* @param {string} walletId
|
|
5548
5719
|
* @param {string} requestId
|
|
5549
5720
|
* @param {WmpClientRequestBody} wmpClientRequestBody
|
|
@@ -5602,6 +5773,17 @@ class DefaultApi extends base_1.BaseAPI {
|
|
|
5602
5773
|
wmpEntityList(walletId, entityType, options) {
|
|
5603
5774
|
return (0, exports.DefaultApiFp)(this.configuration).wmpEntityList(walletId, entityType, options).then((request) => request(this.axios, this.basePath));
|
|
5604
5775
|
}
|
|
5776
|
+
/**
|
|
5777
|
+
* Sends a free-form WMP message to a connected entity. The session is auto-resumed if its transport has dropped. The peer receives it as a `wmp.message` notification and can then read the message metadata from `GET /wmp/client/requests/{request_id}` and download its body via the download link it contains. The request is `multipart/form-data`. Supply the primary body as either the `body` text field (plain text) or a `body` file part (any content type, taken from the part).
|
|
5778
|
+
* @param {string} walletId
|
|
5779
|
+
* @param {string} entityId
|
|
5780
|
+
* @param {File} [body] The primary message body: a plain-text form value, or a file part whose Content-Type becomes the message content type.
|
|
5781
|
+
* @param {*} [options] Override http request option.
|
|
5782
|
+
* @throws {RequiredError}
|
|
5783
|
+
*/
|
|
5784
|
+
wmpEntitySendMessage(walletId, entityId, body, options) {
|
|
5785
|
+
return (0, exports.DefaultApiFp)(this.configuration).wmpEntitySendMessage(walletId, entityId, body, options).then((request) => request(this.axios, this.basePath));
|
|
5786
|
+
}
|
|
5605
5787
|
/**
|
|
5606
5788
|
* Re-establishes or confirms the WebSocket connection to a WMP server entity. Used to reconnect after a dropped connection so the wallet can resume receiving pending requests.
|
|
5607
5789
|
* @param {string} walletId
|
package/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { DefaultApi } from "./api";
|
|
3
|
+
import { WalletNotificationStream, WalletNotificationStreamOptions } from "./notifications";
|
|
3
4
|
export type ClientConfiguration = {
|
|
4
5
|
clientId: string;
|
|
5
6
|
clientSecret: string;
|
|
@@ -14,4 +15,10 @@ export declare class Client extends DefaultApi {
|
|
|
14
15
|
protected baseURL: string;
|
|
15
16
|
protected axios: AxiosInstance;
|
|
16
17
|
constructor(tokenUrl: string, audience: string, clientId: string, clientSecret: string, baseURL: string, axios?: AxiosInstance);
|
|
18
|
+
/**
|
|
19
|
+
* Opens a live stream of notifications for a wallet over SSE.
|
|
20
|
+
* @param walletId Wallet ID
|
|
21
|
+
* @param options Stream filtering/reconnect options
|
|
22
|
+
*/
|
|
23
|
+
streamWalletNotifications(walletId: string, options?: WalletNotificationStreamOptions): WalletNotificationStream;
|
|
17
24
|
}
|
package/client.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Client = void 0;
|
|
7
7
|
const api_1 = require("./api");
|
|
8
|
+
const notifications_1 = require("./notifications");
|
|
8
9
|
const axios_1 = __importDefault(require("axios"));
|
|
9
10
|
const auth_1 = require("./auth");
|
|
10
11
|
/**
|
|
@@ -23,6 +24,14 @@ class Client extends api_1.DefaultApi {
|
|
|
23
24
|
this.baseURL = baseURL;
|
|
24
25
|
this.axios = axios;
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Opens a live stream of notifications for a wallet over SSE.
|
|
29
|
+
* @param walletId Wallet ID
|
|
30
|
+
* @param options Stream filtering/reconnect options
|
|
31
|
+
*/
|
|
32
|
+
streamWalletNotifications(walletId, options = {}) {
|
|
33
|
+
return new notifications_1.WalletNotificationStream(this.configuration, walletId, Object.assign({ axios: this.axios, basePath: this.basePath }, options));
|
|
34
|
+
}
|
|
26
35
|
}
|
|
27
36
|
exports.Client = Client;
|
|
28
37
|
function isJsonMime(mime) {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-written client for the `walletNotifications` SSE endpoint.
|
|
3
|
+
*
|
|
4
|
+
* This file is NOT managed by the OpenAPI generator (see .openapi-generator/FILES) -
|
|
5
|
+
* it builds on top of the generated request builder in `api.ts` to provide an
|
|
6
|
+
* ergonomic Node.js client for the `GET /wallets/{wallet_id}/notifications`
|
|
7
|
+
* `text/event-stream` endpoint, including reconnect-with-replay via `Last-Event-ID`.
|
|
8
|
+
*/
|
|
9
|
+
import { EventEmitter } from 'events';
|
|
10
|
+
import type { AxiosInstance } from 'axios';
|
|
11
|
+
import { Configuration } from './configuration';
|
|
12
|
+
import { WalletNotification } from './api';
|
|
13
|
+
export interface WalletNotificationStreamOptions {
|
|
14
|
+
/** Filter the stream to a single notification event type. */
|
|
15
|
+
eventType?: string;
|
|
16
|
+
/** Filter the stream to a single notification state. */
|
|
17
|
+
state?: string;
|
|
18
|
+
/** Resume the stream after this event ID (queued notification replay). */
|
|
19
|
+
lastEventId?: string;
|
|
20
|
+
/** Axios instance to use for the underlying request. Defaults to the global axios instance. */
|
|
21
|
+
axios?: AxiosInstance;
|
|
22
|
+
/** Overrides the base path used to reach the API. */
|
|
23
|
+
basePath?: string;
|
|
24
|
+
/** Automatically reconnect (with replay via Last-Event-ID) when the stream drops. Defaults to true. */
|
|
25
|
+
reconnect?: boolean;
|
|
26
|
+
/** Delay before reconnecting when the server hasn't sent an SSE `retry:` field. Defaults to 3000ms. */
|
|
27
|
+
retryDelayMs?: number;
|
|
28
|
+
/** Upper bound for the reconnect delay, including any server-provided `retry:` value. Defaults to 30000ms. */
|
|
29
|
+
maxRetryDelayMs?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare interface WalletNotificationStream {
|
|
32
|
+
on(event: 'open', listener: () => void): this;
|
|
33
|
+
on(event: 'notification', listener: (notification: WalletNotification) => void): this;
|
|
34
|
+
on(event: 'error', listener: (error: Error) => void): this;
|
|
35
|
+
on(event: 'close', listener: () => void): this;
|
|
36
|
+
once(event: 'open', listener: () => void): this;
|
|
37
|
+
once(event: 'notification', listener: (notification: WalletNotification) => void): this;
|
|
38
|
+
once(event: 'error', listener: (error: Error) => void): this;
|
|
39
|
+
once(event: 'close', listener: () => void): this;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Live stream of wallet notifications over `GET /wallets/{wallet_id}/notifications`.
|
|
43
|
+
*
|
|
44
|
+
* Emits `open`, `notification`, `error` and `close` events, and is itself an
|
|
45
|
+
* async iterable of {@link WalletNotification}:
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* const stream = new WalletNotificationStream(configuration, walletId);
|
|
49
|
+
* for await (const notification of stream) {
|
|
50
|
+
* console.log(notification);
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* Drops are reconnected automatically (replaying queued notifications via
|
|
55
|
+
* `Last-Event-ID`) unless `options.reconnect` is set to `false`.
|
|
56
|
+
*/
|
|
57
|
+
export declare class WalletNotificationStream extends EventEmitter implements AsyncIterable<WalletNotification> {
|
|
58
|
+
private readonly configuration;
|
|
59
|
+
private readonly walletId;
|
|
60
|
+
private readonly axiosInstance;
|
|
61
|
+
private readonly basePath;
|
|
62
|
+
private readonly eventType?;
|
|
63
|
+
private readonly state?;
|
|
64
|
+
private readonly reconnect;
|
|
65
|
+
private readonly retryDelayMs;
|
|
66
|
+
private readonly maxRetryDelayMs;
|
|
67
|
+
private lastEventId?;
|
|
68
|
+
private nextRetryDelayMs?;
|
|
69
|
+
private abortController?;
|
|
70
|
+
private retryTimer?;
|
|
71
|
+
private closed;
|
|
72
|
+
private readonly queue;
|
|
73
|
+
private readonly waiters;
|
|
74
|
+
constructor(configuration: Configuration, walletId: string, options?: WalletNotificationStreamOptions);
|
|
75
|
+
/** Stops the stream and prevents further reconnection attempts. */
|
|
76
|
+
close(): void;
|
|
77
|
+
get isClosed(): boolean;
|
|
78
|
+
private connect;
|
|
79
|
+
private scheduleReconnect;
|
|
80
|
+
private dispatchToQueue;
|
|
81
|
+
private settleWaiters;
|
|
82
|
+
[Symbol.asyncIterator](): AsyncIterator<WalletNotification>;
|
|
83
|
+
}
|
package/notifications.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hand-written client for the `walletNotifications` SSE endpoint.
|
|
4
|
+
*
|
|
5
|
+
* This file is NOT managed by the OpenAPI generator (see .openapi-generator/FILES) -
|
|
6
|
+
* it builds on top of the generated request builder in `api.ts` to provide an
|
|
7
|
+
* ergonomic Node.js client for the `GET /wallets/{wallet_id}/notifications`
|
|
8
|
+
* `text/event-stream` endpoint, including reconnect-with-replay via `Last-Event-ID`.
|
|
9
|
+
*/
|
|
10
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
16
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
20
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
21
|
+
var m = o[Symbol.asyncIterator], i;
|
|
22
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
23
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
24
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
25
|
+
};
|
|
26
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
27
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
28
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
29
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
30
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
31
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
32
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
33
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
34
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
35
|
+
function fulfill(value) { resume("next", value); }
|
|
36
|
+
function reject(value) { resume("throw", value); }
|
|
37
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
38
|
+
};
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.WalletNotificationStream = void 0;
|
|
44
|
+
const events_1 = require("events");
|
|
45
|
+
const axios_1 = __importDefault(require("axios"));
|
|
46
|
+
const base_1 = require("./base");
|
|
47
|
+
const common_1 = require("./common");
|
|
48
|
+
const api_1 = require("./api");
|
|
49
|
+
/**
|
|
50
|
+
* Parses a raw byte/text stream into Server-Sent Events per the WHATWG spec
|
|
51
|
+
* (https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation).
|
|
52
|
+
*/
|
|
53
|
+
function parseSseStream(source) {
|
|
54
|
+
return __asyncGenerator(this, arguments, function* parseSseStream_1() {
|
|
55
|
+
var _a, e_1, _b, _c;
|
|
56
|
+
let buffer = '';
|
|
57
|
+
let eventType;
|
|
58
|
+
let dataLines = [];
|
|
59
|
+
let id;
|
|
60
|
+
let sawData = false;
|
|
61
|
+
function takeEvent() {
|
|
62
|
+
const event = sawData
|
|
63
|
+
? { kind: 'event', id, event: eventType, data: dataLines.join('\n') }
|
|
64
|
+
: undefined;
|
|
65
|
+
eventType = undefined;
|
|
66
|
+
dataLines = [];
|
|
67
|
+
sawData = false;
|
|
68
|
+
return event;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
for (var _d = true, source_1 = __asyncValues(source), source_1_1; source_1_1 = yield __await(source_1.next()), _a = source_1_1.done, !_a; _d = true) {
|
|
72
|
+
_c = source_1_1.value;
|
|
73
|
+
_d = false;
|
|
74
|
+
const chunk = _c;
|
|
75
|
+
buffer += typeof chunk === 'string' ? chunk : chunk.toString('utf8');
|
|
76
|
+
let newlineIndex;
|
|
77
|
+
while ((newlineIndex = buffer.indexOf('\n')) >= 0) {
|
|
78
|
+
let line = buffer.slice(0, newlineIndex);
|
|
79
|
+
buffer = buffer.slice(newlineIndex + 1);
|
|
80
|
+
if (line.endsWith('\r')) {
|
|
81
|
+
line = line.slice(0, -1);
|
|
82
|
+
}
|
|
83
|
+
if (line === '') {
|
|
84
|
+
const event = takeEvent();
|
|
85
|
+
if (event)
|
|
86
|
+
yield yield __await(event);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (line.startsWith(':')) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const colonIndex = line.indexOf(':');
|
|
93
|
+
const field = colonIndex === -1 ? line : line.slice(0, colonIndex);
|
|
94
|
+
let value = colonIndex === -1 ? '' : line.slice(colonIndex + 1);
|
|
95
|
+
if (value.startsWith(' '))
|
|
96
|
+
value = value.slice(1);
|
|
97
|
+
switch (field) {
|
|
98
|
+
case 'event':
|
|
99
|
+
eventType = value;
|
|
100
|
+
break;
|
|
101
|
+
case 'data':
|
|
102
|
+
dataLines.push(value);
|
|
103
|
+
sawData = true;
|
|
104
|
+
break;
|
|
105
|
+
case 'id':
|
|
106
|
+
// Per spec, an id field containing a NUL character is ignored.
|
|
107
|
+
if (!value.includes('\u0000'))
|
|
108
|
+
id = value;
|
|
109
|
+
break;
|
|
110
|
+
case 'retry':
|
|
111
|
+
// Unlike `data`/`id`, `retry` is not part of a dispatched event - it
|
|
112
|
+
// just updates the reconnection delay for future reconnects.
|
|
113
|
+
if (/^\d+$/.test(value))
|
|
114
|
+
yield yield __await({ kind: 'retry', delayMs: parseInt(value, 10) });
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
121
|
+
finally {
|
|
122
|
+
try {
|
|
123
|
+
if (!_d && !_a && (_b = source_1.return)) yield __await(_b.call(source_1));
|
|
124
|
+
}
|
|
125
|
+
finally { if (e_1) throw e_1.error; }
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Live stream of wallet notifications over `GET /wallets/{wallet_id}/notifications`.
|
|
131
|
+
*
|
|
132
|
+
* Emits `open`, `notification`, `error` and `close` events, and is itself an
|
|
133
|
+
* async iterable of {@link WalletNotification}:
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
136
|
+
* const stream = new WalletNotificationStream(configuration, walletId);
|
|
137
|
+
* for await (const notification of stream) {
|
|
138
|
+
* console.log(notification);
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* Drops are reconnected automatically (replaying queued notifications via
|
|
143
|
+
* `Last-Event-ID`) unless `options.reconnect` is set to `false`.
|
|
144
|
+
*/
|
|
145
|
+
class WalletNotificationStream extends events_1.EventEmitter {
|
|
146
|
+
constructor(configuration, walletId, options = {}) {
|
|
147
|
+
var _a, _b, _c, _d, _e, _f;
|
|
148
|
+
super();
|
|
149
|
+
this.configuration = configuration;
|
|
150
|
+
this.walletId = walletId;
|
|
151
|
+
this.closed = false;
|
|
152
|
+
this.queue = [];
|
|
153
|
+
this.waiters = [];
|
|
154
|
+
this.axiosInstance = (_a = options.axios) !== null && _a !== void 0 ? _a : axios_1.default;
|
|
155
|
+
this.basePath = (_c = (_b = options.basePath) !== null && _b !== void 0 ? _b : configuration.basePath) !== null && _c !== void 0 ? _c : base_1.BASE_PATH;
|
|
156
|
+
this.eventType = options.eventType;
|
|
157
|
+
this.state = options.state;
|
|
158
|
+
this.lastEventId = options.lastEventId;
|
|
159
|
+
this.reconnect = (_d = options.reconnect) !== null && _d !== void 0 ? _d : true;
|
|
160
|
+
this.retryDelayMs = (_e = options.retryDelayMs) !== null && _e !== void 0 ? _e : 3000;
|
|
161
|
+
this.maxRetryDelayMs = (_f = options.maxRetryDelayMs) !== null && _f !== void 0 ? _f : 30000;
|
|
162
|
+
void this.connect();
|
|
163
|
+
}
|
|
164
|
+
/** Stops the stream and prevents further reconnection attempts. */
|
|
165
|
+
close() {
|
|
166
|
+
var _a;
|
|
167
|
+
if (this.closed)
|
|
168
|
+
return;
|
|
169
|
+
this.closed = true;
|
|
170
|
+
if (this.retryTimer)
|
|
171
|
+
clearTimeout(this.retryTimer);
|
|
172
|
+
(_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
173
|
+
this.settleWaiters();
|
|
174
|
+
this.emit('close');
|
|
175
|
+
}
|
|
176
|
+
get isClosed() {
|
|
177
|
+
return this.closed;
|
|
178
|
+
}
|
|
179
|
+
connect() {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
var _a, e_2, _b, _c;
|
|
182
|
+
var _d;
|
|
183
|
+
if (this.closed)
|
|
184
|
+
return;
|
|
185
|
+
this.abortController = new AbortController();
|
|
186
|
+
try {
|
|
187
|
+
const requestArgs = yield (0, api_1.DefaultApiAxiosParamCreator)(this.configuration).walletNotifications(this.walletId, this.eventType, this.state, this.lastEventId, { signal: this.abortController.signal, responseType: 'stream' });
|
|
188
|
+
const request = (0, common_1.createRequestFunction)(requestArgs, this.axiosInstance, this.basePath, this.configuration);
|
|
189
|
+
const response = yield request(this.axiosInstance, this.basePath);
|
|
190
|
+
this.emit('open');
|
|
191
|
+
try {
|
|
192
|
+
for (var _e = true, _f = __asyncValues(parseSseStream(response.data)), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) {
|
|
193
|
+
_c = _g.value;
|
|
194
|
+
_e = false;
|
|
195
|
+
const message = _c;
|
|
196
|
+
if (this.closed)
|
|
197
|
+
break;
|
|
198
|
+
if (message.kind === 'retry') {
|
|
199
|
+
this.nextRetryDelayMs = message.delayMs;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (message.id !== undefined)
|
|
203
|
+
this.lastEventId = message.id;
|
|
204
|
+
if (!message.data)
|
|
205
|
+
continue;
|
|
206
|
+
let notification;
|
|
207
|
+
try {
|
|
208
|
+
notification = JSON.parse(message.data);
|
|
209
|
+
}
|
|
210
|
+
catch (_h) {
|
|
211
|
+
this.emit('error', new Error(`Failed to parse wallet notification payload: ${message.data}`));
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
this.emit('notification', notification);
|
|
215
|
+
this.dispatchToQueue(notification);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
219
|
+
finally {
|
|
220
|
+
try {
|
|
221
|
+
if (!_e && !_a && (_b = _f.return)) yield _b.call(_f);
|
|
222
|
+
}
|
|
223
|
+
finally { if (e_2) throw e_2.error; }
|
|
224
|
+
}
|
|
225
|
+
if (this.closed)
|
|
226
|
+
return;
|
|
227
|
+
this.scheduleReconnect();
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
if (this.closed)
|
|
231
|
+
return;
|
|
232
|
+
this.emit('error', err instanceof Error ? err : new Error(String(err)));
|
|
233
|
+
const status = (_d = err === null || err === void 0 ? void 0 : err.response) === null || _d === void 0 ? void 0 : _d.status;
|
|
234
|
+
if (status !== undefined && status >= 400 && status < 500) {
|
|
235
|
+
// Client errors (bad wallet ID, invalid/expired token, ...) won't be fixed by retrying.
|
|
236
|
+
this.close();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
this.scheduleReconnect();
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
scheduleReconnect() {
|
|
244
|
+
var _a;
|
|
245
|
+
if (this.closed || !this.reconnect) {
|
|
246
|
+
this.close();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const delay = Math.min((_a = this.nextRetryDelayMs) !== null && _a !== void 0 ? _a : this.retryDelayMs, this.maxRetryDelayMs);
|
|
250
|
+
this.retryTimer = setTimeout(() => void this.connect(), delay);
|
|
251
|
+
}
|
|
252
|
+
dispatchToQueue(notification) {
|
|
253
|
+
const waiter = this.waiters.shift();
|
|
254
|
+
if (waiter) {
|
|
255
|
+
waiter({ value: notification, done: false });
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
this.queue.push(notification);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
settleWaiters() {
|
|
262
|
+
while (this.waiters.length) {
|
|
263
|
+
this.waiters.shift()({ value: undefined, done: true });
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
[Symbol.asyncIterator]() {
|
|
267
|
+
return {
|
|
268
|
+
next: () => {
|
|
269
|
+
if (this.queue.length) {
|
|
270
|
+
return Promise.resolve({ value: this.queue.shift(), done: false });
|
|
271
|
+
}
|
|
272
|
+
if (this.closed) {
|
|
273
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
274
|
+
}
|
|
275
|
+
return new Promise((resolve) => this.waiters.push(resolve));
|
|
276
|
+
},
|
|
277
|
+
return: () => {
|
|
278
|
+
this.close();
|
|
279
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
exports.WalletNotificationStream = WalletNotificationStream;
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@triveria/wallet",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.313",
|
|
5
5
|
"description": "",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/triveria-com/wallet-sdk-ts.git"
|
|
9
|
+
},
|
|
6
10
|
"main": "index.js",
|
|
7
11
|
"scripts": {
|
|
8
12
|
"test": "echo \"Error: no test specified\" && exit 1",
|