@@ -102,7 +102,7 @@ export interface ConfigureVendorArgs {
102
102
/**
103
103
* The vendor url
104
104
*/
105
- vendorUrl : string ;
105
+ url : string ;
106
106
}
107
107
108
108
export interface MessageData < T = unknown > {
@@ -251,19 +251,54 @@ export class ExtensionClient {
251
251
} ;
252
252
253
253
/**
254
- * Configures the extension with the specified vendor.
254
+ * Sends a /signify/authorize message to the extension.
255
+ *
256
+ * The extension should prompt the user to select a identifier,
257
+ * on success, it should send a /signify/reply message back to the browser page.
258
+ *
259
+ * This method is used to start an authorized "session" with the extension. Depending
260
+ * on the implemention, the extension can start to allow "signRequest" messages
261
+ * after a successful authorization.
262
+ *
263
+ * @param payload The arguments to pass to the extension.
264
+ * @returns {AuthorizeResult }
265
+ */
266
+ authorizeAid = async ( payload ?: AuthorizeArgs ) : Promise < AuthorizeResult > => {
267
+ return this . sendMessage ( "/signify/authorize/aid" , { payload } ) ;
268
+ } ;
269
+
270
+ /**
271
+ * Sends a /signify/authorize message to the extension.
272
+ *
273
+ * The extension should prompt the user to select a credential,
274
+ * on success, it should send a /signify/reply message back to the browser page.
275
+ *
276
+ * This method is used to start an authorized "session" with the extension. Depending
277
+ * on the implemention, the extension can start to allow "signRequest" messages
278
+ * after a successful authorization.
255
279
*
280
+ * @param payload The arguments to pass to the extension.
281
+ * @returns {AuthorizeResult }
282
+ */
283
+ authorizeCred = async ( payload ?: AuthorizeArgs ) : Promise < AuthorizeResult > => {
284
+ return this . sendMessage ( "/signify/authorize/credential" , { payload } ) ;
285
+ } ;
286
+
287
+ /**
288
+ * Configures the extension with the specified vendor.
256
289
* @param payload The vendor configuration
290
+ * @summary Tries to set the vendor url in the extension to load vendor supplied info e.g theme, logo etc.
291
+ * @example
292
+ * ```ts
293
+ * await signifyClient.provideConfigUrl({url: "https://api.npoint.io/52639f849bb31823a8c0"});
294
+ * ```
295
+ * @remarks
296
+ * This function is used to set the vendor url in the extension. The extension will fetch the vendor supplied info from the vendor url in json format.
297
+ *
298
+ * @see Template for [Vendor Loaded JSON](https://api.npoint.io/52639f849bb31823a8c0)
257
299
*/
258
300
configureVendor = async ( payload ?: ConfigureVendorArgs ) : Promise < void > => {
259
- window . postMessage (
260
- {
261
- type : "vendor-info" ,
262
- subtype : "attempt-set-vendor-url" ,
263
- data : payload ,
264
- } ,
265
- this . options . targetOrigin ?? "/" ,
266
- ) ;
301
+ return this . sendMessage ( "/signify/configure-vendor" , { payload } ) ;
267
302
} ;
268
303
269
304
/**
@@ -299,7 +334,7 @@ export class ExtensionClient {
299
334
} ) ;
300
335
} ) ;
301
336
302
- window . postMessage ( { requestId, type, ...payload } , this . options . targetOrigin ?? "/" ) ;
337
+ window . postMessage ( { requestId, type, ...( payload ?? { } ) } , this . options . targetOrigin ?? "/" ) ;
303
338
304
339
return promise ;
305
340
} ;
0 commit comments