-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(push-notifications)!: align to RFCs 0699/0734 (#223)
Signed-off-by: Ariel Gentile <[email protected]>
- Loading branch information
Showing
37 changed files
with
475 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 14 additions & 2 deletions
16
packages/push-notifications/src/apns/PushNotificationsApnsModule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/push-notifications/src/apns/errors/PushNotificationsApnsProblemReportError.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { PushNotificationsApnsProblemReportReason } from './PushNotificationsApnsProblemReportReason' | ||
import type { ProblemReportErrorOptions } from '@aries-framework/core' | ||
|
||
import { ProblemReportError } from '@aries-framework/core' | ||
|
||
import { PushNotificationsApnsProblemReportMessage } from '../messages' | ||
|
||
/** | ||
* @internal | ||
*/ | ||
interface PushNotificationsApnsProblemReportErrorOptions extends ProblemReportErrorOptions { | ||
problemCode: PushNotificationsApnsProblemReportReason | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export class PushNotificationsApnsProblemReportError extends ProblemReportError { | ||
public problemReport: PushNotificationsApnsProblemReportMessage | ||
|
||
public constructor(public message: string, { problemCode }: PushNotificationsApnsProblemReportErrorOptions) { | ||
super(message, { problemCode }) | ||
this.problemReport = new PushNotificationsApnsProblemReportMessage({ | ||
description: { | ||
en: message, | ||
code: problemCode, | ||
}, | ||
}) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/push-notifications/src/apns/errors/PushNotificationsApnsProblemReportReason.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Push Notification APNS errors discussed in RFC 0699. | ||
* | ||
* @see https://github.com/hyperledger/aries-rfcs/tree/main/features/0699-push-notifications-apns#set-device-info | ||
* @see https://github.com/hyperledger/aries-rfcs/tree/main/features/0699-push-notifications-apns#device-info | ||
* @internal | ||
*/ | ||
export enum PushNotificationsApnsProblemReportReason { | ||
MissingValue = 'missing-value', | ||
NotRegistered = 'not-registered-for-push-notifications', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './PushNotificationsApnsProblemReportReason' | ||
export * from './PushNotificationsApnsProblemReportError' |
18 changes: 18 additions & 0 deletions
18
packages/push-notifications/src/apns/handlers/PushNotificationsApnsProblemReportHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { MessageHandler, MessageHandlerInboundMessage } from '@aries-framework/core' | ||
|
||
import { PushNotificationsApnsProblemReportMessage } from '../messages' | ||
|
||
/** | ||
* Handler for incoming push notification problem report messages | ||
*/ | ||
export class PushNotificationsApnsProblemReportHandler implements MessageHandler { | ||
public supportedMessages = [PushNotificationsApnsProblemReportMessage] | ||
|
||
/** | ||
/* We don't really need to do anything with this at the moment | ||
/* The result can be hooked into through the generic message processed event | ||
*/ | ||
public async handle(inboundMessage: MessageHandlerInboundMessage<PushNotificationsApnsProblemReportHandler>) { | ||
inboundMessage.assertReadyConnection() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { PushNotificationsApnsGetDeviceInfoHandler } from './PushNotificationsApnsGetDeviceInfoHandler' | ||
export { PushNotificationsApnsSetDeviceInfoHandler } from './PushNotificationsApnsSetDeviceInfoHandler' | ||
export { PushNotificationsApnsDeviceInfoHandler } from './PushNotificationsApnsDeviceInfoHandler' | ||
export { PushNotificationsApnsProblemReportHandler } from './PushNotificationsApnsProblemReportHandler' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/push-notifications/src/apns/messages/PushNotificationsApnsProblemReportMessage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { ProblemReportMessageOptions } from '@aries-framework/core' | ||
|
||
import { IsValidMessageType, parseMessageType, ProblemReportMessage } from '@aries-framework/core' | ||
|
||
export type PushNotificationsApnsProblemReportMessageOptions = ProblemReportMessageOptions | ||
|
||
/** | ||
* @see https://github.com/hyperledger/aries-rfcs/blob/main/features/0035-report-problem/README.md | ||
* @internal | ||
*/ | ||
export class PushNotificationsApnsProblemReportMessage extends ProblemReportMessage { | ||
/** | ||
* Create new ConnectionProblemReportMessage instance. | ||
* @param options | ||
*/ | ||
public constructor(options: PushNotificationsApnsProblemReportMessageOptions) { | ||
super(options) | ||
} | ||
|
||
@IsValidMessageType(PushNotificationsApnsProblemReportMessage.type) | ||
public readonly type = PushNotificationsApnsProblemReportMessage.type.messageTypeUri | ||
public static readonly type = parseMessageType('https://didcomm.org/push-notifications-apns/1.0/problem-report') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { PushNotificationsApnsGetDeviceInfoMessage } from './PushNotificationsApnsGetDeviceInfoMessage' | ||
export { PushNotificationsApnsSetDeviceInfoMessage } from './PushNotificationsApnsSetDeviceInfoMessage' | ||
export { PushNotificationsApnsDeviceInfoMessage } from './PushNotificationsApnsDeviceInfoMessage' | ||
export { PushNotificationsApnsProblemReportMessage } from './PushNotificationsApnsProblemReportMessage' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export type ApnsDeviceInfo = { | ||
deviceToken: string | ||
deviceToken: string | null | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/push-notifications/src/apns/models/PushNotificationsApnsRole.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Push Notification FCM roles based on the flow defined in RFC 0699. | ||
* | ||
* @see https://github.com/hyperledger/aries-rfcs/tree/main/features/0699-push-notifications-apns#roles | ||
* @public | ||
*/ | ||
export enum PushNotificationsApnsRole { | ||
Sender = 'notification-sender', | ||
Receiver = 'notification-receiver', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './ApnsDeviceInfo' | ||
export * from './PushNotificationsApnsRole' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 14 additions & 2 deletions
16
packages/push-notifications/src/fcm/PushNotificationsFcmModule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,40 @@ | ||
import type { DependencyManager, Module } from '@aries-framework/core' | ||
import type { DependencyManager, FeatureRegistry, Module } from '@aries-framework/core' | ||
|
||
import { Protocol } from '@aries-framework/core' | ||
|
||
import { PushNotificationsFcmApi } from './PushNotificationsFcmApi' | ||
import { PushNotificationsFcmService } from './PushNotificationsFcmService' | ||
import { | ||
PushNotificationsFcmDeviceInfoHandler, | ||
PushNotificationsFcmGetDeviceInfoHandler, | ||
PushNotificationsFcmProblemReportHandler, | ||
PushNotificationsFcmSetDeviceInfoHandler, | ||
} from './handlers' | ||
import { PushNotificationsFcmRole } from './models' | ||
|
||
/** | ||
* Module that exposes push notification get and set functionality | ||
*/ | ||
export class PushNotificationsFcmModule implements Module { | ||
public readonly api = PushNotificationsFcmApi | ||
|
||
public register(dependencyManager: DependencyManager): void { | ||
public register(dependencyManager: DependencyManager, featureRegistry: FeatureRegistry): void { | ||
dependencyManager.registerContextScoped(PushNotificationsFcmApi) | ||
|
||
dependencyManager.registerSingleton(PushNotificationsFcmService) | ||
|
||
featureRegistry.register( | ||
new Protocol({ | ||
id: 'https://didcomm.org/push-notifications-fcm/1.0', | ||
roles: [PushNotificationsFcmRole.Sender, PushNotificationsFcmRole.Receiver], | ||
}) | ||
) | ||
|
||
dependencyManager.registerMessageHandlers([ | ||
new PushNotificationsFcmDeviceInfoHandler(), | ||
new PushNotificationsFcmGetDeviceInfoHandler(), | ||
new PushNotificationsFcmSetDeviceInfoHandler(), | ||
new PushNotificationsFcmProblemReportHandler(), | ||
]) | ||
} | ||
} |
Oops, something went wrong.