fix field name inside packed tickets
[squeep-indie-auther] / src / manager.js
index 0d4302772b7405ce4539cb55640d5a3b9da011a1..2b64ed16b14f50558b614b2b33afc2ca4f2145e9 100644 (file)
@@ -28,7 +28,8 @@ class Manager {
     if (options.queues.amqp.url) {
       this.queuePublisher = new QueuePublisher(logger, options.queues.amqp);
     }
-    this.mysteryBox = new MysteryBox(logger, options);
+    this.mysteryBox = new MysteryBox(options);
+    this.mysteryBox.on('statistics', common.mysteryBoxLogger(logger, _fileScope(this.constructor.name)));
 
     // We need to know how the outside world sees us, to verify if a
     // profile indicates us as the auth server.
@@ -1196,7 +1197,7 @@ class Manager {
     const nowEpoch = common.dateToEpoch();
     return this.mysteryBox.pack({
       c: common.requestId(),
-      iss: nowEpoch,
+      iat: nowEpoch,
       exp: nowEpoch + ticketLifespanSeconds,
       sub: subject,
       res: resource,
@@ -1227,7 +1228,7 @@ class Manager {
     const ticketObj = await this.mysteryBox.unpack(ticket);
     return {
       codeId: ticketObj.c,
-      issued: new Date(ticketObj.iss * 1000),
+      issued: new Date(ticketObj.iat * 1000),
       expires: new Date(ticketObj.exp * 1000),
       subject: new URL(ticketObj.sub),
       resource: new URL(ticketObj.res),
@@ -1526,7 +1527,7 @@ class Manager {
       }
 
       try {
-        const result = await this.queuePublisher.publish(queueName, { ticket, resource, subject });
+        const result = await this.queuePublisher.publish(queueName, { ticket, resource, subject, epochMs: Date.now() });
         this.logger.debug(_scope, 'accepted ticket offer', { queueName, ticket, resource, subject, ctx, result });
       } catch (e) {
         this.logger.error(_scope, 'failed to publish ticket to queue', { error: e, queueName, ticket, resource, subject, ctx });
@@ -1933,7 +1934,7 @@ class Manager {
 
             try {
               const result = await this.communication.deliverTicket(ctx.ticketEndpointUrl, ctx.ticketResourceUrl, ctx.ticketSubjectUrl, ticket);
-              ctx.notifications.push(`Success! Ticket was delivered. (${result?.statusText})`);
+              ctx.notifications.push(`Success! Ticket was delivered. (${result?.statusMessage})`);
               this.logger.info(_scope, 'ticket delivered', { ctx, result });
             } catch (e) {
               this.logger.error(_scope, 'failed to deliver ticket', { ctx, error: e });