@chipmobilesdk/rn-notification 0.5.0 → 0.7.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.
- package/CHANGELOG.md +184 -0
- package/README.md +108 -16
- package/lib/commonjs/advanced.js +139 -0
- package/lib/commonjs/advanced.js.map +1 -0
- package/lib/commonjs/channel/migrate.js +246 -0
- package/lib/commonjs/channel/migrate.js.map +1 -0
- package/lib/commonjs/channel/tone-map.js +120 -0
- package/lib/commonjs/channel/tone-map.js.map +1 -0
- package/lib/commonjs/channel/validate-tone.js +61 -0
- package/lib/commonjs/channel/validate-tone.js.map +1 -0
- package/lib/commonjs/contract/channel.js +52 -0
- package/lib/commonjs/contract/channel.js.map +1 -0
- package/lib/commonjs/contract/diagnostics.js +25 -0
- package/lib/commonjs/contract/diagnostics.js.map +1 -0
- package/lib/commonjs/contract/errors.js +126 -0
- package/lib/commonjs/contract/errors.js.map +1 -0
- package/lib/commonjs/contract/hash.js +35 -0
- package/lib/commonjs/contract/hash.js.map +1 -0
- package/lib/commonjs/contract/index.js +94 -0
- package/lib/commonjs/contract/index.js.map +1 -0
- package/lib/commonjs/contract/interaction.js +37 -0
- package/lib/commonjs/contract/interaction.js.map +1 -0
- package/lib/commonjs/contract/notification.js +42 -0
- package/lib/commonjs/contract/notification.js.map +1 -0
- package/lib/commonjs/contract/permission.js +2 -0
- package/lib/commonjs/contract/permission.js.map +1 -0
- package/lib/commonjs/contract/reconcile.js +6 -0
- package/lib/commonjs/contract/reconcile.js.map +1 -0
- package/lib/commonjs/contract/recurrence.js +53 -0
- package/lib/commonjs/contract/recurrence.js.map +1 -0
- package/lib/commonjs/diagnostics/burst.js +89 -0
- package/lib/commonjs/diagnostics/burst.js.map +1 -0
- package/lib/commonjs/diagnostics/events.js +63 -0
- package/lib/commonjs/diagnostics/events.js.map +1 -0
- package/lib/commonjs/diagnostics/redact.js +48 -0
- package/lib/commonjs/diagnostics/redact.js.map +1 -0
- package/lib/commonjs/diagnostics/snapshot.js +68 -0
- package/lib/commonjs/diagnostics/snapshot.js.map +1 -0
- package/lib/commonjs/engine/adapter.js +6 -0
- package/lib/commonjs/engine/adapter.js.map +1 -0
- package/lib/commonjs/engine/codec.js +84 -0
- package/lib/commonjs/engine/codec.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/events.js +148 -0
- package/lib/commonjs/engine/notify-kit/events.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/module.js +119 -0
- package/lib/commonjs/engine/notify-kit/module.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/android.js +159 -0
- package/lib/commonjs/engine/notify-kit/platform/android.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/index.js +57 -0
- package/lib/commonjs/engine/notify-kit/platform/index.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/ios.js +54 -0
- package/lib/commonjs/engine/notify-kit/platform/ios.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/types.js +6 -0
- package/lib/commonjs/engine/notify-kit/platform/types.js.map +1 -0
- package/lib/commonjs/engine/notify-kit-engine.js +260 -0
- package/lib/commonjs/engine/notify-kit-engine.js.map +1 -0
- package/lib/commonjs/index.js +367 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/initialize.js +187 -0
- package/lib/commonjs/initialize.js.map +1 -0
- package/lib/commonjs/interaction/index.js +120 -0
- package/lib/commonjs/interaction/index.js.map +1 -0
- package/lib/commonjs/maintenance/cycle.js +108 -0
- package/lib/commonjs/maintenance/cycle.js.map +1 -0
- package/lib/commonjs/maintenance/permission-refresh.js +39 -0
- package/lib/commonjs/maintenance/permission-refresh.js.map +1 -0
- package/lib/commonjs/maintenance/reanchor.js +99 -0
- package/lib/commonjs/maintenance/reanchor.js.map +1 -0
- package/lib/commonjs/maintenance/toggle.js +50 -0
- package/lib/commonjs/maintenance/toggle.js.map +1 -0
- package/lib/commonjs/maintenance/verify.js +70 -0
- package/lib/commonjs/maintenance/verify.js.map +1 -0
- package/lib/commonjs/maintenance/window-refresh.js +53 -0
- package/lib/commonjs/maintenance/window-refresh.js.map +1 -0
- package/lib/commonjs/notifications.js +161 -0
- package/lib/commonjs/notifications.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/permission/index.js +182 -0
- package/lib/commonjs/permission/index.js.map +1 -0
- package/lib/commonjs/permission/state.js +92 -0
- package/lib/commonjs/permission/state.js.map +1 -0
- package/lib/commonjs/push/envelope.js +141 -0
- package/lib/commonjs/push/envelope.js.map +1 -0
- package/lib/commonjs/push/fcm-provider.js +122 -0
- package/lib/commonjs/push/fcm-provider.js.map +1 -0
- package/lib/commonjs/push/gate.js +162 -0
- package/lib/commonjs/push/gate.js.map +1 -0
- package/lib/commonjs/push/index.js +47 -0
- package/lib/commonjs/push/index.js.map +1 -0
- package/lib/commonjs/push/instructions.js +101 -0
- package/lib/commonjs/push/instructions.js.map +1 -0
- package/lib/commonjs/push/provider-adapter.js +6 -0
- package/lib/commonjs/push/provider-adapter.js.map +1 -0
- package/lib/commonjs/push/signout.js +55 -0
- package/lib/commonjs/push/signout.js.map +1 -0
- package/lib/commonjs/reconcile/chunk.js +49 -0
- package/lib/commonjs/reconcile/chunk.js.map +1 -0
- package/lib/commonjs/reconcile/diff.js +105 -0
- package/lib/commonjs/reconcile/diff.js.map +1 -0
- package/lib/commonjs/reconcile/duplicates.js +60 -0
- package/lib/commonjs/reconcile/duplicates.js.map +1 -0
- package/lib/commonjs/reconcile/index.js +164 -0
- package/lib/commonjs/reconcile/index.js.map +1 -0
- package/lib/commonjs/reconcile/truncate.js +50 -0
- package/lib/commonjs/reconcile/truncate.js.map +1 -0
- package/lib/commonjs/recurrence/clock-guard.js +65 -0
- package/lib/commonjs/recurrence/clock-guard.js.map +1 -0
- package/lib/commonjs/recurrence/expand.js +254 -0
- package/lib/commonjs/recurrence/expand.js.map +1 -0
- package/lib/commonjs/recurrence/index.js +212 -0
- package/lib/commonjs/recurrence/index.js.map +1 -0
- package/lib/commonjs/repeat/expiry.js +41 -0
- package/lib/commonjs/repeat/expiry.js.map +1 -0
- package/lib/commonjs/repeat/index.js +100 -0
- package/lib/commonjs/repeat/index.js.map +1 -0
- package/lib/commonjs/repeat/marker.js +58 -0
- package/lib/commonjs/repeat/marker.js.map +1 -0
- package/lib/commonjs/repeat/place.js +83 -0
- package/lib/commonjs/repeat/place.js.map +1 -0
- package/lib/commonjs/schedule/anchor.js +243 -0
- package/lib/commonjs/schedule/anchor.js.map +1 -0
- package/lib/commonjs/schedule/index.js +142 -0
- package/lib/commonjs/schedule/index.js.map +1 -0
- package/lib/commonjs/schedule/partition.js +59 -0
- package/lib/commonjs/schedule/partition.js.map +1 -0
- package/lib/commonjs/schedule/resolve-moment.js +72 -0
- package/lib/commonjs/schedule/resolve-moment.js.map +1 -0
- package/lib/commonjs/schedule/validate-content.js +101 -0
- package/lib/commonjs/schedule/validate-content.js.map +1 -0
- package/lib/commonjs/schedule/validate-identifier.js +126 -0
- package/lib/commonjs/schedule/validate-identifier.js.map +1 -0
- package/lib/commonjs/schedule/writer.js +44 -0
- package/lib/commonjs/schedule/writer.js.map +1 -0
- package/lib/commonjs/state/caps.js +101 -0
- package/lib/commonjs/state/caps.js.map +1 -0
- package/lib/commonjs/state/dedup-ledger.js +39 -0
- package/lib/commonjs/state/dedup-ledger.js.map +1 -0
- package/lib/commonjs/state/interaction-buffer.js +98 -0
- package/lib/commonjs/state/interaction-buffer.js.map +1 -0
- package/lib/commonjs/state/mmkv-store.js +75 -0
- package/lib/commonjs/state/mmkv-store.js.map +1 -0
- package/lib/commonjs/state/permission-history.js +64 -0
- package/lib/commonjs/state/permission-history.js.map +1 -0
- package/lib/commonjs/state/record.js +269 -0
- package/lib/commonjs/state/record.js.map +1 -0
- package/lib/commonjs/state/reset.js +37 -0
- package/lib/commonjs/state/reset.js.map +1 -0
- package/lib/commonjs/state/series-ledger.js +71 -0
- package/lib/commonjs/state/series-ledger.js.map +1 -0
- package/lib/commonjs/state/store.js +39 -0
- package/lib/commonjs/state/store.js.map +1 -0
- package/lib/commonjs/testing/conformance/index.js +218 -0
- package/lib/commonjs/testing/conformance/index.js.map +1 -0
- package/lib/commonjs/testing/fake-engine.js +338 -0
- package/lib/commonjs/testing/fake-engine.js.map +1 -0
- package/lib/commonjs/testing/fake-provider.js +93 -0
- package/lib/commonjs/testing/fake-provider.js.map +1 -0
- package/lib/commonjs/testing/faults.js +59 -0
- package/lib/commonjs/testing/faults.js.map +1 -0
- package/lib/commonjs/testing/index.js +54 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/testing/measure.js +298 -0
- package/lib/commonjs/testing/measure.js.map +1 -0
- package/lib/module/advanced.js +29 -0
- package/lib/module/advanced.js.map +1 -0
- package/lib/module/channel/migrate.js +242 -0
- package/lib/module/channel/migrate.js.map +1 -0
- package/lib/module/channel/tone-map.js +112 -0
- package/lib/module/channel/tone-map.js.map +1 -0
- package/lib/module/channel/validate-tone.js +57 -0
- package/lib/module/channel/validate-tone.js.map +1 -0
- package/lib/module/contract/channel.js +48 -0
- package/lib/module/contract/channel.js.map +1 -0
- package/lib/module/contract/diagnostics.js +21 -0
- package/lib/module/contract/diagnostics.js.map +1 -0
- package/lib/module/contract/errors.js +119 -0
- package/lib/module/contract/errors.js.map +1 -0
- package/lib/module/contract/hash.js +29 -0
- package/lib/module/contract/hash.js.map +1 -0
- package/lib/module/contract/index.js +13 -0
- package/lib/module/contract/index.js.map +1 -0
- package/lib/module/contract/interaction.js +33 -0
- package/lib/module/contract/interaction.js.map +1 -0
- package/lib/module/contract/notification.js +38 -0
- package/lib/module/contract/notification.js.map +1 -0
- package/lib/module/contract/permission.js +2 -0
- package/lib/module/contract/permission.js.map +1 -0
- package/lib/module/contract/reconcile.js +4 -0
- package/lib/module/contract/reconcile.js.map +1 -0
- package/lib/module/contract/recurrence.js +49 -0
- package/lib/module/contract/recurrence.js.map +1 -0
- package/lib/module/diagnostics/burst.js +85 -0
- package/lib/module/diagnostics/burst.js.map +1 -0
- package/lib/module/diagnostics/events.js +58 -0
- package/lib/module/diagnostics/events.js.map +1 -0
- package/lib/module/diagnostics/redact.js +44 -0
- package/lib/module/diagnostics/redact.js.map +1 -0
- package/lib/module/diagnostics/snapshot.js +64 -0
- package/lib/module/diagnostics/snapshot.js.map +1 -0
- package/lib/module/engine/adapter.js +4 -0
- package/lib/module/engine/adapter.js.map +1 -0
- package/lib/module/engine/codec.js +79 -0
- package/lib/module/engine/codec.js.map +1 -0
- package/lib/module/engine/notify-kit/events.js +139 -0
- package/lib/module/engine/notify-kit/events.js.map +1 -0
- package/lib/module/engine/notify-kit/module.js +113 -0
- package/lib/module/engine/notify-kit/module.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/android.js +155 -0
- package/lib/module/engine/notify-kit/platform/android.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/index.js +51 -0
- package/lib/module/engine/notify-kit/platform/index.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/ios.js +49 -0
- package/lib/module/engine/notify-kit/platform/ios.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/types.js +4 -0
- package/lib/module/engine/notify-kit/platform/types.js.map +1 -0
- package/lib/module/engine/notify-kit-engine.js +257 -0
- package/lib/module/engine/notify-kit-engine.js.map +1 -0
- package/lib/module/index.js +98 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/initialize.js +182 -0
- package/lib/module/initialize.js.map +1 -0
- package/lib/module/interaction/index.js +116 -0
- package/lib/module/interaction/index.js.map +1 -0
- package/lib/module/maintenance/cycle.js +102 -0
- package/lib/module/maintenance/cycle.js.map +1 -0
- package/lib/module/maintenance/permission-refresh.js +34 -0
- package/lib/module/maintenance/permission-refresh.js.map +1 -0
- package/lib/module/maintenance/reanchor.js +94 -0
- package/lib/module/maintenance/reanchor.js.map +1 -0
- package/lib/module/maintenance/toggle.js +45 -0
- package/lib/module/maintenance/toggle.js.map +1 -0
- package/lib/module/maintenance/verify.js +65 -0
- package/lib/module/maintenance/verify.js.map +1 -0
- package/lib/module/maintenance/window-refresh.js +48 -0
- package/lib/module/maintenance/window-refresh.js.map +1 -0
- package/lib/module/notifications.js +157 -0
- package/lib/module/notifications.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permission/index.js +178 -0
- package/lib/module/permission/index.js.map +1 -0
- package/lib/module/permission/state.js +83 -0
- package/lib/module/permission/state.js.map +1 -0
- package/lib/module/push/envelope.js +137 -0
- package/lib/module/push/envelope.js.map +1 -0
- package/lib/module/push/fcm-provider.js +119 -0
- package/lib/module/push/fcm-provider.js.map +1 -0
- package/lib/module/push/gate.js +158 -0
- package/lib/module/push/gate.js.map +1 -0
- package/lib/module/push/index.js +16 -0
- package/lib/module/push/index.js.map +1 -0
- package/lib/module/push/instructions.js +97 -0
- package/lib/module/push/instructions.js.map +1 -0
- package/lib/module/push/provider-adapter.js +4 -0
- package/lib/module/push/provider-adapter.js.map +1 -0
- package/lib/module/push/signout.js +51 -0
- package/lib/module/push/signout.js.map +1 -0
- package/lib/module/reconcile/chunk.js +43 -0
- package/lib/module/reconcile/chunk.js.map +1 -0
- package/lib/module/reconcile/diff.js +101 -0
- package/lib/module/reconcile/diff.js.map +1 -0
- package/lib/module/reconcile/duplicates.js +56 -0
- package/lib/module/reconcile/duplicates.js.map +1 -0
- package/lib/module/reconcile/index.js +161 -0
- package/lib/module/reconcile/index.js.map +1 -0
- package/lib/module/reconcile/truncate.js +46 -0
- package/lib/module/reconcile/truncate.js.map +1 -0
- package/lib/module/recurrence/clock-guard.js +60 -0
- package/lib/module/recurrence/clock-guard.js.map +1 -0
- package/lib/module/recurrence/expand.js +248 -0
- package/lib/module/recurrence/expand.js.map +1 -0
- package/lib/module/recurrence/index.js +208 -0
- package/lib/module/recurrence/index.js.map +1 -0
- package/lib/module/repeat/expiry.js +37 -0
- package/lib/module/repeat/expiry.js.map +1 -0
- package/lib/module/repeat/index.js +67 -0
- package/lib/module/repeat/index.js.map +1 -0
- package/lib/module/repeat/marker.js +51 -0
- package/lib/module/repeat/marker.js.map +1 -0
- package/lib/module/repeat/place.js +79 -0
- package/lib/module/repeat/place.js.map +1 -0
- package/lib/module/schedule/anchor.js +234 -0
- package/lib/module/schedule/anchor.js.map +1 -0
- package/lib/module/schedule/index.js +137 -0
- package/lib/module/schedule/index.js.map +1 -0
- package/lib/module/schedule/partition.js +53 -0
- package/lib/module/schedule/partition.js.map +1 -0
- package/lib/module/schedule/resolve-moment.js +66 -0
- package/lib/module/schedule/resolve-moment.js.map +1 -0
- package/lib/module/schedule/validate-content.js +95 -0
- package/lib/module/schedule/validate-content.js.map +1 -0
- package/lib/module/schedule/validate-identifier.js +119 -0
- package/lib/module/schedule/validate-identifier.js.map +1 -0
- package/lib/module/schedule/writer.js +40 -0
- package/lib/module/schedule/writer.js.map +1 -0
- package/lib/module/state/caps.js +96 -0
- package/lib/module/state/caps.js.map +1 -0
- package/lib/module/state/dedup-ledger.js +34 -0
- package/lib/module/state/dedup-ledger.js.map +1 -0
- package/lib/module/state/interaction-buffer.js +92 -0
- package/lib/module/state/interaction-buffer.js.map +1 -0
- package/lib/module/state/mmkv-store.js +71 -0
- package/lib/module/state/mmkv-store.js.map +1 -0
- package/lib/module/state/permission-history.js +56 -0
- package/lib/module/state/permission-history.js.map +1 -0
- package/lib/module/state/record.js +264 -0
- package/lib/module/state/record.js.map +1 -0
- package/lib/module/state/reset.js +32 -0
- package/lib/module/state/reset.js.map +1 -0
- package/lib/module/state/series-ledger.js +62 -0
- package/lib/module/state/series-ledger.js.map +1 -0
- package/lib/module/state/store.js +35 -0
- package/lib/module/state/store.js.map +1 -0
- package/lib/module/testing/conformance/index.js +214 -0
- package/lib/module/testing/conformance/index.js.map +1 -0
- package/lib/module/testing/fake-engine.js +335 -0
- package/lib/module/testing/fake-engine.js.map +1 -0
- package/lib/module/testing/fake-provider.js +89 -0
- package/lib/module/testing/fake-provider.js.map +1 -0
- package/lib/module/testing/faults.js +55 -0
- package/lib/module/testing/faults.js.map +1 -0
- package/lib/module/testing/index.js +19 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/module/testing/measure.js +294 -0
- package/lib/module/testing/measure.js.map +1 -0
- package/lib/typescript/commonjs/advanced.d.ts +36 -0
- package/lib/typescript/commonjs/advanced.d.ts.map +1 -0
- package/lib/typescript/commonjs/channel/migrate.d.ts +38 -0
- package/lib/typescript/commonjs/channel/migrate.d.ts.map +1 -0
- package/lib/typescript/commonjs/channel/tone-map.d.ts +34 -0
- package/lib/typescript/commonjs/channel/tone-map.d.ts.map +1 -0
- package/lib/typescript/commonjs/channel/validate-tone.d.ts +23 -0
- package/lib/typescript/commonjs/channel/validate-tone.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/channel.d.ts +185 -0
- package/lib/typescript/commonjs/contract/channel.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/diagnostics.d.ts +92 -0
- package/lib/typescript/commonjs/contract/diagnostics.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/errors.d.ts +91 -0
- package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/hash.d.ts +14 -0
- package/lib/typescript/commonjs/contract/hash.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/index.d.ts +10 -0
- package/lib/typescript/commonjs/contract/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts +53 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/notification.d.ts +110 -0
- package/lib/typescript/commonjs/contract/notification.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/permission.d.ts +49 -0
- package/lib/typescript/commonjs/contract/permission.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/reconcile.d.ts +82 -0
- package/lib/typescript/commonjs/contract/reconcile.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/recurrence.d.ts +118 -0
- package/lib/typescript/commonjs/contract/recurrence.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/burst.d.ts +39 -0
- package/lib/typescript/commonjs/diagnostics/burst.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/events.d.ts +28 -0
- package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts +22 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/snapshot.d.ts +40 -0
- package/lib/typescript/commonjs/diagnostics/snapshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/adapter.d.ts +172 -0
- package/lib/typescript/commonjs/engine/adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/codec.d.ts +20 -0
- package/lib/typescript/commonjs/engine/codec.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/events.d.ts +37 -0
- package/lib/typescript/commonjs/engine/notify-kit/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/module.d.ts +103 -0
- package/lib/typescript/commonjs/engine/notify-kit/module.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts +3 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts +12 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts +3 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts +33 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts +25 -0
- package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +106 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/initialize.d.ts +74 -0
- package/lib/typescript/commonjs/initialize.d.ts.map +1 -0
- package/lib/typescript/commonjs/interaction/index.d.ts +53 -0
- package/lib/typescript/commonjs/interaction/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/cycle.d.ts +77 -0
- package/lib/typescript/commonjs/maintenance/cycle.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts +19 -0
- package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/reanchor.d.ts +26 -0
- package/lib/typescript/commonjs/maintenance/reanchor.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/toggle.d.ts +35 -0
- package/lib/typescript/commonjs/maintenance/toggle.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/verify.d.ts +32 -0
- package/lib/typescript/commonjs/maintenance/verify.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/window-refresh.d.ts +29 -0
- package/lib/typescript/commonjs/maintenance/window-refresh.d.ts.map +1 -0
- package/lib/typescript/commonjs/notifications.d.ts +78 -0
- package/lib/typescript/commonjs/notifications.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/permission/index.d.ts +57 -0
- package/lib/typescript/commonjs/permission/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/permission/state.d.ts +41 -0
- package/lib/typescript/commonjs/permission/state.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/envelope.d.ts +33 -0
- package/lib/typescript/commonjs/push/envelope.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/fcm-provider.d.ts +43 -0
- package/lib/typescript/commonjs/push/fcm-provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/gate.d.ts +57 -0
- package/lib/typescript/commonjs/push/gate.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/index.d.ts +19 -0
- package/lib/typescript/commonjs/push/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/instructions.d.ts +45 -0
- package/lib/typescript/commonjs/push/instructions.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/provider-adapter.d.ts +50 -0
- package/lib/typescript/commonjs/push/provider-adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/signout.d.ts +33 -0
- package/lib/typescript/commonjs/push/signout.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/chunk.d.ts +24 -0
- package/lib/typescript/commonjs/reconcile/chunk.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/diff.d.ts +54 -0
- package/lib/typescript/commonjs/reconcile/diff.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/duplicates.d.ts +32 -0
- package/lib/typescript/commonjs/reconcile/duplicates.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/index.d.ts +35 -0
- package/lib/typescript/commonjs/reconcile/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/truncate.d.ts +26 -0
- package/lib/typescript/commonjs/reconcile/truncate.d.ts.map +1 -0
- package/lib/typescript/commonjs/recurrence/clock-guard.d.ts +37 -0
- package/lib/typescript/commonjs/recurrence/clock-guard.d.ts.map +1 -0
- package/lib/typescript/commonjs/recurrence/expand.d.ts +75 -0
- package/lib/typescript/commonjs/recurrence/expand.d.ts.map +1 -0
- package/lib/typescript/commonjs/recurrence/index.d.ts +40 -0
- package/lib/typescript/commonjs/recurrence/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/expiry.d.ts +23 -0
- package/lib/typescript/commonjs/repeat/expiry.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/index.d.ts +49 -0
- package/lib/typescript/commonjs/repeat/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/marker.d.ts +36 -0
- package/lib/typescript/commonjs/repeat/marker.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/place.d.ts +39 -0
- package/lib/typescript/commonjs/repeat/place.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/anchor.d.ts +118 -0
- package/lib/typescript/commonjs/schedule/anchor.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/index.d.ts +40 -0
- package/lib/typescript/commonjs/schedule/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/partition.d.ts +29 -0
- package/lib/typescript/commonjs/schedule/partition.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/resolve-moment.d.ts +35 -0
- package/lib/typescript/commonjs/schedule/resolve-moment.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/validate-content.d.ts +42 -0
- package/lib/typescript/commonjs/schedule/validate-content.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/validate-identifier.d.ts +30 -0
- package/lib/typescript/commonjs/schedule/validate-identifier.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/writer.d.ts +36 -0
- package/lib/typescript/commonjs/schedule/writer.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/caps.d.ts +51 -0
- package/lib/typescript/commonjs/state/caps.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/dedup-ledger.d.ts +21 -0
- package/lib/typescript/commonjs/state/dedup-ledger.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/interaction-buffer.d.ts +30 -0
- package/lib/typescript/commonjs/state/interaction-buffer.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/mmkv-store.d.ts +33 -0
- package/lib/typescript/commonjs/state/mmkv-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/permission-history.d.ts +20 -0
- package/lib/typescript/commonjs/state/permission-history.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/record.d.ts +134 -0
- package/lib/typescript/commonjs/state/record.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/reset.d.ts +22 -0
- package/lib/typescript/commonjs/state/reset.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/series-ledger.d.ts +47 -0
- package/lib/typescript/commonjs/state/series-ledger.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/store.d.ts +20 -0
- package/lib/typescript/commonjs/state/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts +32 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/fake-engine.d.ts +91 -0
- package/lib/typescript/commonjs/testing/fake-engine.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/fake-provider.d.ts +35 -0
- package/lib/typescript/commonjs/testing/fake-provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/faults.d.ts +38 -0
- package/lib/typescript/commonjs/testing/faults.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +22 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/measure.d.ts +59 -0
- package/lib/typescript/commonjs/testing/measure.d.ts.map +1 -0
- package/lib/typescript/module/advanced.d.ts +36 -0
- package/lib/typescript/module/advanced.d.ts.map +1 -0
- package/lib/typescript/module/channel/migrate.d.ts +38 -0
- package/lib/typescript/module/channel/migrate.d.ts.map +1 -0
- package/lib/typescript/module/channel/tone-map.d.ts +34 -0
- package/lib/typescript/module/channel/tone-map.d.ts.map +1 -0
- package/lib/typescript/module/channel/validate-tone.d.ts +23 -0
- package/lib/typescript/module/channel/validate-tone.d.ts.map +1 -0
- package/lib/typescript/module/contract/channel.d.ts +185 -0
- package/lib/typescript/module/contract/channel.d.ts.map +1 -0
- package/lib/typescript/module/contract/diagnostics.d.ts +92 -0
- package/lib/typescript/module/contract/diagnostics.d.ts.map +1 -0
- package/lib/typescript/module/contract/errors.d.ts +91 -0
- package/lib/typescript/module/contract/errors.d.ts.map +1 -0
- package/lib/typescript/module/contract/hash.d.ts +14 -0
- package/lib/typescript/module/contract/hash.d.ts.map +1 -0
- package/lib/typescript/module/contract/index.d.ts +10 -0
- package/lib/typescript/module/contract/index.d.ts.map +1 -0
- package/lib/typescript/module/contract/interaction.d.ts +53 -0
- package/lib/typescript/module/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/module/contract/notification.d.ts +110 -0
- package/lib/typescript/module/contract/notification.d.ts.map +1 -0
- package/lib/typescript/module/contract/permission.d.ts +49 -0
- package/lib/typescript/module/contract/permission.d.ts.map +1 -0
- package/lib/typescript/module/contract/reconcile.d.ts +82 -0
- package/lib/typescript/module/contract/reconcile.d.ts.map +1 -0
- package/lib/typescript/module/contract/recurrence.d.ts +118 -0
- package/lib/typescript/module/contract/recurrence.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/burst.d.ts +39 -0
- package/lib/typescript/module/diagnostics/burst.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/events.d.ts +28 -0
- package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/redact.d.ts +22 -0
- package/lib/typescript/module/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/snapshot.d.ts +40 -0
- package/lib/typescript/module/diagnostics/snapshot.d.ts.map +1 -0
- package/lib/typescript/module/engine/adapter.d.ts +172 -0
- package/lib/typescript/module/engine/adapter.d.ts.map +1 -0
- package/lib/typescript/module/engine/codec.d.ts +20 -0
- package/lib/typescript/module/engine/codec.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/events.d.ts +37 -0
- package/lib/typescript/module/engine/notify-kit/events.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/module.d.ts +103 -0
- package/lib/typescript/module/engine/notify-kit/module.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/android.d.ts +3 -0
- package/lib/typescript/module/engine/notify-kit/platform/android.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/index.d.ts +12 -0
- package/lib/typescript/module/engine/notify-kit/platform/index.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts +3 -0
- package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/types.d.ts +33 -0
- package/lib/typescript/module/engine/notify-kit/platform/types.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit-engine.d.ts +25 -0
- package/lib/typescript/module/engine/notify-kit-engine.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +106 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/initialize.d.ts +74 -0
- package/lib/typescript/module/initialize.d.ts.map +1 -0
- package/lib/typescript/module/interaction/index.d.ts +53 -0
- package/lib/typescript/module/interaction/index.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/cycle.d.ts +77 -0
- package/lib/typescript/module/maintenance/cycle.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/permission-refresh.d.ts +19 -0
- package/lib/typescript/module/maintenance/permission-refresh.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/reanchor.d.ts +26 -0
- package/lib/typescript/module/maintenance/reanchor.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/toggle.d.ts +35 -0
- package/lib/typescript/module/maintenance/toggle.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/verify.d.ts +32 -0
- package/lib/typescript/module/maintenance/verify.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/window-refresh.d.ts +29 -0
- package/lib/typescript/module/maintenance/window-refresh.d.ts.map +1 -0
- package/lib/typescript/module/notifications.d.ts +78 -0
- package/lib/typescript/module/notifications.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/permission/index.d.ts +57 -0
- package/lib/typescript/module/permission/index.d.ts.map +1 -0
- package/lib/typescript/module/permission/state.d.ts +41 -0
- package/lib/typescript/module/permission/state.d.ts.map +1 -0
- package/lib/typescript/module/push/envelope.d.ts +33 -0
- package/lib/typescript/module/push/envelope.d.ts.map +1 -0
- package/lib/typescript/module/push/fcm-provider.d.ts +43 -0
- package/lib/typescript/module/push/fcm-provider.d.ts.map +1 -0
- package/lib/typescript/module/push/gate.d.ts +57 -0
- package/lib/typescript/module/push/gate.d.ts.map +1 -0
- package/lib/typescript/module/push/index.d.ts +19 -0
- package/lib/typescript/module/push/index.d.ts.map +1 -0
- package/lib/typescript/module/push/instructions.d.ts +45 -0
- package/lib/typescript/module/push/instructions.d.ts.map +1 -0
- package/lib/typescript/module/push/provider-adapter.d.ts +50 -0
- package/lib/typescript/module/push/provider-adapter.d.ts.map +1 -0
- package/lib/typescript/module/push/signout.d.ts +33 -0
- package/lib/typescript/module/push/signout.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/chunk.d.ts +24 -0
- package/lib/typescript/module/reconcile/chunk.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/diff.d.ts +54 -0
- package/lib/typescript/module/reconcile/diff.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/duplicates.d.ts +32 -0
- package/lib/typescript/module/reconcile/duplicates.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/index.d.ts +35 -0
- package/lib/typescript/module/reconcile/index.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/truncate.d.ts +26 -0
- package/lib/typescript/module/reconcile/truncate.d.ts.map +1 -0
- package/lib/typescript/module/recurrence/clock-guard.d.ts +37 -0
- package/lib/typescript/module/recurrence/clock-guard.d.ts.map +1 -0
- package/lib/typescript/module/recurrence/expand.d.ts +75 -0
- package/lib/typescript/module/recurrence/expand.d.ts.map +1 -0
- package/lib/typescript/module/recurrence/index.d.ts +40 -0
- package/lib/typescript/module/recurrence/index.d.ts.map +1 -0
- package/lib/typescript/module/repeat/expiry.d.ts +23 -0
- package/lib/typescript/module/repeat/expiry.d.ts.map +1 -0
- package/lib/typescript/module/repeat/index.d.ts +49 -0
- package/lib/typescript/module/repeat/index.d.ts.map +1 -0
- package/lib/typescript/module/repeat/marker.d.ts +36 -0
- package/lib/typescript/module/repeat/marker.d.ts.map +1 -0
- package/lib/typescript/module/repeat/place.d.ts +39 -0
- package/lib/typescript/module/repeat/place.d.ts.map +1 -0
- package/lib/typescript/module/schedule/anchor.d.ts +118 -0
- package/lib/typescript/module/schedule/anchor.d.ts.map +1 -0
- package/lib/typescript/module/schedule/index.d.ts +40 -0
- package/lib/typescript/module/schedule/index.d.ts.map +1 -0
- package/lib/typescript/module/schedule/partition.d.ts +29 -0
- package/lib/typescript/module/schedule/partition.d.ts.map +1 -0
- package/lib/typescript/module/schedule/resolve-moment.d.ts +35 -0
- package/lib/typescript/module/schedule/resolve-moment.d.ts.map +1 -0
- package/lib/typescript/module/schedule/validate-content.d.ts +42 -0
- package/lib/typescript/module/schedule/validate-content.d.ts.map +1 -0
- package/lib/typescript/module/schedule/validate-identifier.d.ts +30 -0
- package/lib/typescript/module/schedule/validate-identifier.d.ts.map +1 -0
- package/lib/typescript/module/schedule/writer.d.ts +36 -0
- package/lib/typescript/module/schedule/writer.d.ts.map +1 -0
- package/lib/typescript/module/state/caps.d.ts +51 -0
- package/lib/typescript/module/state/caps.d.ts.map +1 -0
- package/lib/typescript/module/state/dedup-ledger.d.ts +21 -0
- package/lib/typescript/module/state/dedup-ledger.d.ts.map +1 -0
- package/lib/typescript/module/state/interaction-buffer.d.ts +30 -0
- package/lib/typescript/module/state/interaction-buffer.d.ts.map +1 -0
- package/lib/typescript/module/state/mmkv-store.d.ts +33 -0
- package/lib/typescript/module/state/mmkv-store.d.ts.map +1 -0
- package/lib/typescript/module/state/permission-history.d.ts +20 -0
- package/lib/typescript/module/state/permission-history.d.ts.map +1 -0
- package/lib/typescript/module/state/record.d.ts +134 -0
- package/lib/typescript/module/state/record.d.ts.map +1 -0
- package/lib/typescript/module/state/reset.d.ts +22 -0
- package/lib/typescript/module/state/reset.d.ts.map +1 -0
- package/lib/typescript/module/state/series-ledger.d.ts +47 -0
- package/lib/typescript/module/state/series-ledger.d.ts.map +1 -0
- package/lib/typescript/module/state/store.d.ts +20 -0
- package/lib/typescript/module/state/store.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/index.d.ts +32 -0
- package/lib/typescript/module/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/fake-engine.d.ts +91 -0
- package/lib/typescript/module/testing/fake-engine.d.ts.map +1 -0
- package/lib/typescript/module/testing/fake-provider.d.ts +35 -0
- package/lib/typescript/module/testing/fake-provider.d.ts.map +1 -0
- package/lib/typescript/module/testing/faults.d.ts +38 -0
- package/lib/typescript/module/testing/faults.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +22 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/measure.d.ts +59 -0
- package/lib/typescript/module/testing/measure.d.ts.map +1 -0
- package/package.json +74 -23
- package/skills/sdk-rn-notification/SKILL.md +6 -5
- package/src/advanced.ts +35 -0
- package/src/channel/migrate.ts +176 -158
- package/src/channel/tone-map.ts +2 -10
- package/src/contract/errors.ts +7 -0
- package/src/contract/hash.ts +26 -0
- package/src/engine/adapter.ts +21 -1
- package/src/engine/notify-kit/events.ts +155 -0
- package/src/engine/notify-kit/module.ts +148 -0
- package/src/engine/notify-kit/platform/android.ts +172 -0
- package/src/engine/notify-kit/platform/index.ts +55 -0
- package/src/engine/notify-kit/platform/ios.ts +54 -0
- package/src/engine/notify-kit/platform/types.ts +40 -0
- package/src/engine/notify-kit-engine.ts +96 -477
- package/src/index.ts +9 -0
- package/src/notifications.ts +195 -0
- package/src/permission/index.ts +65 -4
- package/src/push/fcm-provider.ts +14 -4
- package/src/push/gate.ts +27 -5
- package/src/reconcile/diff.ts +38 -27
- package/src/reconcile/index.ts +13 -4
- package/src/recurrence/index.ts +2 -1
- package/src/repeat/expiry.ts +2 -6
- package/src/repeat/index.ts +45 -1
- package/src/repeat/marker.ts +1 -22
- package/src/repeat/place.ts +74 -35
- package/src/schedule/index.ts +10 -4
- package/src/schedule/partition.ts +0 -19
- package/src/schedule/validate-identifier.ts +8 -6
- package/src/schedule/writer.ts +13 -4
- package/src/state/caps.ts +28 -3
- package/src/state/permission-history.ts +25 -0
- package/src/state/record.ts +110 -20
- package/src/testing/fake-engine.ts +17 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createPermissions = createPermissions;
|
|
7
|
+
var _errors = require("../contract/errors.js");
|
|
8
|
+
var _state = require("./state.js");
|
|
9
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
10
|
+
var _permissionHistory = require("../state/permission-history.js");
|
|
11
|
+
/**
|
|
12
|
+
* Permission coordination.
|
|
13
|
+
*
|
|
14
|
+
* Two rules shape everything here. Reading state never prompts, so the consumer
|
|
15
|
+
* decides when the user is asked — a prompt at the wrong moment is a permanent
|
|
16
|
+
* denial. And a refusal never fails the caller's business operation: the user's
|
|
17
|
+
* actual work completes, and the lost capability is reported separately.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Refusals after which the system stops showing its prompt (NOT-12). Android 13+
|
|
22
|
+
* allows a second ask; iOS allows one.
|
|
23
|
+
*/
|
|
24
|
+
function denialLimit(platform) {
|
|
25
|
+
return platform.os === 'android' ? 2 : 1;
|
|
26
|
+
}
|
|
27
|
+
function createPermissions(deps) {
|
|
28
|
+
const emit = deps.emit ?? (() => {});
|
|
29
|
+
let listeners = [];
|
|
30
|
+
let lastReport;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The engine's answer plus what only the package remembers. The platform
|
|
34
|
+
* reports a refusal as `denied` however often it happened; once the user has
|
|
35
|
+
* refused as many times as the system will ask, another request shows nothing,
|
|
36
|
+
* so the state is `permanentlyDenied` and the app should offer Settings.
|
|
37
|
+
*/
|
|
38
|
+
const derive = (kind, raw) => {
|
|
39
|
+
const state = (0, _state.normalizeState)(kind, raw, deps.platform);
|
|
40
|
+
if (kind !== 'display') return state;
|
|
41
|
+
if (state === 'granted' || state === 'provisional') {
|
|
42
|
+
(0, _permissionHistory.clearDenials)(deps.state, kind);
|
|
43
|
+
return state;
|
|
44
|
+
}
|
|
45
|
+
return state === 'denied' && (0, _permissionHistory.denialCount)(deps.state, kind) >= denialLimit(deps.platform) ? 'permanentlyDenied' : state;
|
|
46
|
+
};
|
|
47
|
+
const read = async () => {
|
|
48
|
+
// Never prompts. This is what lets a consumer decide the moment to ask.
|
|
49
|
+
const [display, exactAlarm] = await Promise.all([deps.engine.getPermission('display'), deps.engine.getPermission('exactAlarm')]);
|
|
50
|
+
return {
|
|
51
|
+
display: derive('display', display),
|
|
52
|
+
exactAlarm: derive('exactAlarm', exactAlarm),
|
|
53
|
+
readAt: deps.now()
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const whenForeground = deps.onForeground ?? (listener => (0, _rnCore.onForeground)(listener));
|
|
57
|
+
let stopAwaitingSettings;
|
|
58
|
+
/**
|
|
59
|
+
* Exact alarms are granted on a system settings screen, so the answer read
|
|
60
|
+
* straight after opening it is always the old one. The real answer is read
|
|
61
|
+
* when the user comes back, and listeners hear it then (NOT-12).
|
|
62
|
+
*/
|
|
63
|
+
const rereadOnReturn = () => {
|
|
64
|
+
stopAwaitingSettings?.();
|
|
65
|
+
stopAwaitingSettings = whenForeground(() => {
|
|
66
|
+
stopAwaitingSettings?.();
|
|
67
|
+
stopAwaitingSettings = undefined;
|
|
68
|
+
read().then(notifyIfChanged, () => undefined);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const notifyIfChanged = report => {
|
|
72
|
+
const changed = lastReport === undefined || lastReport.display !== report.display || lastReport.exactAlarm !== report.exactAlarm;
|
|
73
|
+
lastReport = report;
|
|
74
|
+
if (!changed) return false;
|
|
75
|
+
for (const listener of listeners) {
|
|
76
|
+
try {
|
|
77
|
+
listener(report);
|
|
78
|
+
} catch {
|
|
79
|
+
// A consumer's handler must never break permission reading.
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
const request = async (kind, ownerTag) => {
|
|
85
|
+
const capability = (0, _state.capabilityFor)(kind, deps.platform);
|
|
86
|
+
|
|
87
|
+
// Requesting something the platform version does not have is a no-op that
|
|
88
|
+
// shows no dialog, rather than a refusal.
|
|
89
|
+
if (!capability.supported) {
|
|
90
|
+
return 'notRequired';
|
|
91
|
+
}
|
|
92
|
+
(0, _permissionHistory.recordRequested)(deps.state, kind, deps.now(), ownerTag);
|
|
93
|
+
const raw = await deps.engine.requestPermission(kind);
|
|
94
|
+
if (kind === 'display' && (0, _state.normalizeState)(kind, raw, deps.platform) === 'denied') {
|
|
95
|
+
(0, _permissionHistory.recordDenial)(deps.state, kind, deps.now());
|
|
96
|
+
}
|
|
97
|
+
const result = derive(kind, raw);
|
|
98
|
+
if (capability.settingsOnly && result !== 'granted') {
|
|
99
|
+
rereadOnReturn();
|
|
100
|
+
}
|
|
101
|
+
if (result === 'denied' || result === 'permanentlyDenied') {
|
|
102
|
+
emit(kind === 'display' ? result === 'permanentlyDenied' ? _errors.DIAGNOSTIC_CODES.DISPLAY_PERMISSION_PERMANENT : _errors.DIAGNOSTIC_CODES.DISPLAY_PERMISSION_DENIED : _errors.DIAGNOSTIC_CODES.EXACT_ALARM_UNAVAILABLE, kind === 'display' ? "Display permission was refused. The caller's operation still succeeded; notifications will not be shown until this is granted." : 'Exact-alarm capability is unavailable. Notifications are still scheduled, in approximate mode, and may be delivered late.', {
|
|
103
|
+
kind,
|
|
104
|
+
state: result
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
notifyIfChanged(await read());
|
|
108
|
+
return result;
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
/** Reads every permission state without triggering any dialog. */
|
|
112
|
+
async getPermissions() {
|
|
113
|
+
const report = await read();
|
|
114
|
+
notifyIfChanged(report);
|
|
115
|
+
return report;
|
|
116
|
+
},
|
|
117
|
+
/** Requested independently — an app may need one and not the other. */
|
|
118
|
+
requestDisplayPermission(ownerTag) {
|
|
119
|
+
return request('display', ownerTag);
|
|
120
|
+
},
|
|
121
|
+
requestExactAlarmPermission(ownerTag) {
|
|
122
|
+
return request('exactAlarm', ownerTag);
|
|
123
|
+
},
|
|
124
|
+
/** Whether the package has ever asked — the platform cannot answer this. */
|
|
125
|
+
hasEverRequested(kind, ownerTag) {
|
|
126
|
+
return (0, _permissionHistory.hasRequested)(deps.state, kind, ownerTag);
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* Opens the settings screen for one specific permission.
|
|
130
|
+
*
|
|
131
|
+
* Telling a user to "find it in settings" is how you lose them, so a
|
|
132
|
+
* platform with no reachable screen is an error rather than a silent no-op.
|
|
133
|
+
*/
|
|
134
|
+
async openSettings(kind) {
|
|
135
|
+
if (!(0, _state.capabilityFor)(kind, deps.platform).supported) {
|
|
136
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.SETTINGS_UNAVAILABLE, `No settings screen exists for ${kind} on this platform version.`, {
|
|
137
|
+
kind,
|
|
138
|
+
os: deps.platform.os,
|
|
139
|
+
apiLevel: deps.platform.apiLevel
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
await deps.engine.openSettings(kind);
|
|
143
|
+
},
|
|
144
|
+
onPermissionChange(handler) {
|
|
145
|
+
listeners.push(handler);
|
|
146
|
+
return () => {
|
|
147
|
+
listeners = listeners.filter(l => l !== handler);
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
/**
|
|
151
|
+
* Manufacturer background restrictions, reported for information only.
|
|
152
|
+
*
|
|
153
|
+
* `unknown` is a first-class answer: some vendors stop apps in ways with no
|
|
154
|
+
* detection API, and guessing would be worse than admitting it. The package
|
|
155
|
+
* changes none of these settings on the user's behalf.
|
|
156
|
+
*/
|
|
157
|
+
async getBackgroundRestrictions() {
|
|
158
|
+
const report = await deps.engine.getRestrictions();
|
|
159
|
+
if (report.batteryOptimization === 'restricted' || report.autoStart === 'restricted') {
|
|
160
|
+
emit(_errors.DIAGNOSTIC_CODES.BACKGROUND_RESTRICTED, 'The device applies a manufacturer background restriction. Notifications may be delayed or suppressed.', {
|
|
161
|
+
battery: report.batteryOptimization,
|
|
162
|
+
autoStart: report.autoStart
|
|
163
|
+
});
|
|
164
|
+
} else if (report.batteryOptimization === 'unknown' || report.autoStart === 'unknown') {
|
|
165
|
+
emit(_errors.DIAGNOSTIC_CODES.BACKGROUND_RESTRICTION_UNKNOWN, 'Manufacturer background restriction could not be determined on this device. Reported as unknown rather than guessed.', {
|
|
166
|
+
battery: report.batteryOptimization,
|
|
167
|
+
autoStart: report.autoStart
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return report;
|
|
171
|
+
},
|
|
172
|
+
/** Called by the permission-refresh maintenance step. */
|
|
173
|
+
async refresh() {
|
|
174
|
+
const report = await read();
|
|
175
|
+
return {
|
|
176
|
+
report,
|
|
177
|
+
changed: notifyIfChanged(report)
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","_state","_rnCore","_permissionHistory","denialLimit","platform","os","createPermissions","deps","emit","listeners","lastReport","derive","kind","raw","state","normalizeState","clearDenials","denialCount","read","display","exactAlarm","Promise","all","engine","getPermission","readAt","now","whenForeground","onForeground","listener","onAppForeground","stopAwaitingSettings","rereadOnReturn","undefined","then","notifyIfChanged","report","changed","request","ownerTag","capability","capabilityFor","supported","recordRequested","requestPermission","recordDenial","result","settingsOnly","DIAGNOSTIC_CODES","DISPLAY_PERMISSION_PERMANENT","DISPLAY_PERMISSION_DENIED","EXACT_ALARM_UNAVAILABLE","getPermissions","requestDisplayPermission","requestExactAlarmPermission","hasEverRequested","hasRequested","openSettings","NotificationError","SETTINGS_UNAVAILABLE","apiLevel","onPermissionChange","handler","push","filter","l","getBackgroundRestrictions","getRestrictions","batteryOptimization","autoStart","BACKGROUND_RESTRICTED","battery","BACKGROUND_RESTRICTION_UNKNOWN","refresh"],"sourceRoot":"../../../src","sources":["permission/index.ts"],"mappings":";;;;;;AAiBA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OA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C,CAAC;MAElD,IAAI/B,MAAM,CAACgC,mBAAmB,KAAK,YAAY,IAAIhC,MAAM,CAACiC,SAAS,KAAK,YAAY,EAAE;QACrF7D,IAAI,CACHwC,wBAAgB,CAACsB,qBAAqB,EACtC,uGAAuG,EACvG;UAAEC,OAAO,EAAEnC,MAAM,CAACgC,mBAAmB;UAAEC,SAAS,EAAEjC,MAAM,CAACiC;QAAU,CACpE,CAAC;MACF,CAAC,MAAM,IAAIjC,MAAM,CAACgC,mBAAmB,KAAK,SAAS,IAAIhC,MAAM,CAACiC,SAAS,KAAK,SAAS,EAAE;QACtF7D,IAAI,CACHwC,wBAAgB,CAACwB,8BAA8B,EAC/C,sHAAsH,EACtH;UAAED,OAAO,EAAEnC,MAAM,CAACgC,mBAAmB;UAAEC,SAAS,EAAEjC,MAAM,CAACiC;QAAU,CACpE,CAAC;MACF;MAEA,OAAOjC,MAAM;IACd,CAAC;IAED;IACA,MAAMqC,OAAOA,CAAA,EAA8E;MAC1F,MAAMrC,MAAM,GAAG,MAAMlB,IAAI,CAAC,CAAC;MAC3B,OAAO;QAAEkB,MAAM;QAAEC,OAAO,EAAEF,eAAe,CAACC,MAAM;MAAE,CAAC;IACpD;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ANDROID_EXACT_ALARM_API = exports.ANDROID_DISPLAY_PERMISSION_API = void 0;
|
|
7
|
+
exports.canDisplay = canDisplay;
|
|
8
|
+
exports.capabilityFor = capabilityFor;
|
|
9
|
+
exports.isTerminal = isTerminal;
|
|
10
|
+
exports.normalizeState = normalizeState;
|
|
11
|
+
exports.shouldOfferSettings = shouldOfferSettings;
|
|
12
|
+
/**
|
|
13
|
+
* The permission state model.
|
|
14
|
+
*
|
|
15
|
+
* Six states, never collapsed. The two that matter most are the ones a naive
|
|
16
|
+
* model loses: `notAsked` must stay distinguishable from `denied`, or reading
|
|
17
|
+
* state without prompting buys nothing; and `notRequired` must never be
|
|
18
|
+
* reported as `denied`, because a platform version with no such concept never
|
|
19
|
+
* refused anything.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** Android runtime notification permission arrived in API 33. */
|
|
23
|
+
const ANDROID_DISPLAY_PERMISSION_API = exports.ANDROID_DISPLAY_PERMISSION_API = 33;
|
|
24
|
+
/** Android exact-alarm permission arrived in API 31. */
|
|
25
|
+
const ANDROID_EXACT_ALARM_API = exports.ANDROID_EXACT_ALARM_API = 31;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a permission concept exists at all on this platform version.
|
|
28
|
+
*
|
|
29
|
+
* Returning `supported: false` is what lets `notRequired` be reported honestly
|
|
30
|
+
* rather than inventing a refusal.
|
|
31
|
+
*/
|
|
32
|
+
function capabilityFor(kind, platform) {
|
|
33
|
+
if (kind === 'display') {
|
|
34
|
+
if (platform.os === 'android' && (platform.apiLevel ?? 0) < ANDROID_DISPLAY_PERMISSION_API) {
|
|
35
|
+
return {
|
|
36
|
+
kind,
|
|
37
|
+
supported: false,
|
|
38
|
+
settingsOnly: false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
kind,
|
|
43
|
+
supported: true,
|
|
44
|
+
settingsOnly: false
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Exact alarms exist only on Android 12+, and are granted through system
|
|
49
|
+
// settings rather than an in-app dialog on the versions that gate them.
|
|
50
|
+
if (platform.os !== 'android' || (platform.apiLevel ?? 0) < ANDROID_EXACT_ALARM_API) {
|
|
51
|
+
return {
|
|
52
|
+
kind,
|
|
53
|
+
supported: false,
|
|
54
|
+
settingsOnly: false
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
kind,
|
|
59
|
+
supported: true,
|
|
60
|
+
settingsOnly: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Normalizes a platform reading into the six-state model. */
|
|
65
|
+
function normalizeState(kind, raw, platform) {
|
|
66
|
+
if (!capabilityFor(kind, platform).supported) {
|
|
67
|
+
return 'notRequired';
|
|
68
|
+
}
|
|
69
|
+
return raw;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Whether a state means the package can still show notifications.
|
|
74
|
+
*
|
|
75
|
+
* `provisional` counts: iOS quiet delivery still reaches the user, just without
|
|
76
|
+
* interrupting them. Treating it as denied would suppress notifications the
|
|
77
|
+
* user is in fact receiving.
|
|
78
|
+
*/
|
|
79
|
+
function canDisplay(state) {
|
|
80
|
+
return state === 'granted' || state === 'provisional' || state === 'notRequired';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Whether asking again could produce a dialog, or whether settings is the only route. */
|
|
84
|
+
function isTerminal(state) {
|
|
85
|
+
return state === 'permanentlyDenied' || state === 'notRequired';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Whether the package has ever asked, which the platform cannot answer after the fact. */
|
|
89
|
+
function shouldOfferSettings(state) {
|
|
90
|
+
return state === 'denied' || state === 'permanentlyDenied';
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ANDROID_DISPLAY_PERMISSION_API","exports","ANDROID_EXACT_ALARM_API","capabilityFor","kind","platform","os","apiLevel","supported","settingsOnly","normalizeState","raw","canDisplay","state","isTerminal","shouldOfferSettings"],"sourceRoot":"../../../src","sources":["permission/state.ts"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACO,MAAMA,8BAA8B,GAAAC,OAAA,CAAAD,8BAAA,GAAG,EAAE;AAChD;AACO,MAAME,uBAAuB,GAAAD,OAAA,CAAAC,uBAAA,GAAG,EAAE;AAQzC;AACA;AAC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,QAAQ,IAAIA,KAAK,KAAK,mBAAmB;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.IMPLEMENTED_PAYLOAD_VERSION = void 0;
|
|
7
|
+
exports.normalizeEnvelope = normalizeEnvelope;
|
|
8
|
+
var _errors = require("../contract/errors.js");
|
|
9
|
+
/**
|
|
10
|
+
* Payload normalization.
|
|
11
|
+
*
|
|
12
|
+
* Every provider's payload is reduced to one envelope shape before it reaches
|
|
13
|
+
* the consumer, so changing provider costs consumer code nothing.
|
|
14
|
+
*
|
|
15
|
+
* Version handling is best-effort: a payload declaring a version this build
|
|
16
|
+
* does not implement is still processed, honouring the fields it understands
|
|
17
|
+
* and ignoring the rest. Servers deploy ahead of app adoption and old app
|
|
18
|
+
* versions live on devices for months, so gating every server-side change on
|
|
19
|
+
* app rollout is the more expensive failure.
|
|
20
|
+
*
|
|
21
|
+
* That is only safe under an append-only discipline — a released field's
|
|
22
|
+
* meaning must never be repurposed. The version-skew diagnostic exists so a
|
|
23
|
+
* misprocessing incident is traceable to the skew rather than investigated as a
|
|
24
|
+
* logic defect.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** The contract version this build implements. */
|
|
28
|
+
const IMPLEMENTED_PAYLOAD_VERSION = exports.IMPLEMENTED_PAYLOAD_VERSION = 1;
|
|
29
|
+
const KINDS = new Set(['display', 'data', 'schedule', 'cancel']);
|
|
30
|
+
function asRecord(value) {
|
|
31
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Text, or nothing.
|
|
36
|
+
*
|
|
37
|
+
* Deliberately not `String(value)`: an object coerces to the literal string
|
|
38
|
+
* "[object Object]", which would be rendered to the user as a notification
|
|
39
|
+
* title. A field that is not text is treated as absent.
|
|
40
|
+
*/
|
|
41
|
+
function asText(value) {
|
|
42
|
+
if (typeof value === 'string') return value;
|
|
43
|
+
if (typeof value === 'number' && Number.isFinite(value)) return String(value);
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** An epoch instant from either a number or an ISO-8601 string. */
|
|
48
|
+
function asInstant(value) {
|
|
49
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
50
|
+
if (typeof value === 'string') return Date.parse(value);
|
|
51
|
+
return Number.NaN;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Extracts and validates the contract version, which every payload must declare. */
|
|
55
|
+
function readVersion(body) {
|
|
56
|
+
const raw = body.v;
|
|
57
|
+
const version = typeof raw === 'number' ? raw : Number.parseInt(asText(raw) ?? '', 10);
|
|
58
|
+
if (!Number.isInteger(version) || version < 1) {
|
|
59
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.PAYLOAD_MALFORMED, 'Push payload carries no usable contract version. Every payload must declare `v` from the first release.', {
|
|
60
|
+
received: typeof raw
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return version;
|
|
64
|
+
}
|
|
65
|
+
function readKind(body) {
|
|
66
|
+
const kind = asText(body.kind);
|
|
67
|
+
if (kind === undefined || !KINDS.has(kind)) {
|
|
68
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.PAYLOAD_MALFORMED, `Push payload declares unknown kind "${kind ?? ''}".`, {
|
|
69
|
+
kind
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return kind;
|
|
73
|
+
}
|
|
74
|
+
function readId(body) {
|
|
75
|
+
const id = asText(body.id);
|
|
76
|
+
if (id === undefined || id.length === 0) {
|
|
77
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.PAYLOAD_MALFORMED, 'Push payload carries no identifier.');
|
|
78
|
+
}
|
|
79
|
+
return id;
|
|
80
|
+
}
|
|
81
|
+
function readContent(body) {
|
|
82
|
+
const content = asRecord(body.content);
|
|
83
|
+
if (content === undefined) return undefined;
|
|
84
|
+
return {
|
|
85
|
+
title: asText(content.title) ?? '',
|
|
86
|
+
body: asText(content.body) ?? '',
|
|
87
|
+
subtitle: asText(content.subtitle)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function readMoment(body) {
|
|
91
|
+
const moment = asRecord(body.moment);
|
|
92
|
+
if (moment === undefined) return undefined;
|
|
93
|
+
return {
|
|
94
|
+
at: asInstant(moment.at),
|
|
95
|
+
anchoring: moment.anchoring === 'absolute' ? 'absolute' : 'wallClock'
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Normalizes a raw provider payload.
|
|
100
|
+
*
|
|
101
|
+
* Throws only for a **structurally unparseable** payload — a broken message.
|
|
102
|
+
* An unrecognized version is a healthy message from a newer contract and must
|
|
103
|
+
* never collapse into the same condition.
|
|
104
|
+
*/
|
|
105
|
+
function normalizeEnvelope(raw, receivedAt) {
|
|
106
|
+
const record = asRecord(raw);
|
|
107
|
+
if (record === undefined) {
|
|
108
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.PAYLOAD_MALFORMED, 'Push payload is not an object and cannot be interpreted.', {
|
|
109
|
+
received: Array.isArray(raw) ? 'array' : typeof raw
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Providers deliver the payload under a data bag; accept either shape so the
|
|
114
|
+
// adapter does not have to reshape before handing it over.
|
|
115
|
+
const body = asRecord(record.data) ?? record;
|
|
116
|
+
const version = readVersion(body);
|
|
117
|
+
const kind = readKind(body);
|
|
118
|
+
const id = readId(body);
|
|
119
|
+
const versionSkew = version !== IMPLEMENTED_PAYLOAD_VERSION;
|
|
120
|
+
return {
|
|
121
|
+
versionSkew,
|
|
122
|
+
envelope: {
|
|
123
|
+
version,
|
|
124
|
+
kind,
|
|
125
|
+
id,
|
|
126
|
+
ownerTag: asText(body.ownerTag),
|
|
127
|
+
content: readContent(body),
|
|
128
|
+
tone: asText(body.tone),
|
|
129
|
+
moment: readMoment(body),
|
|
130
|
+
routing: asRecord(body.routing),
|
|
131
|
+
// Falls back to the identifier, so a server that omits it still gets
|
|
132
|
+
// de-duplication rather than silently losing it.
|
|
133
|
+
dedupId: asText(body.dedupId) ?? id,
|
|
134
|
+
receivedAt,
|
|
135
|
+
versionSkew
|
|
136
|
+
// Fields this build does not understand are simply not read — that is
|
|
137
|
+
// what best-effort processing means in practice.
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","IMPLEMENTED_PAYLOAD_VERSION","exports","KINDS","Set","asRecord","value","Array","isArray","undefined","asText","Number","isFinite","String","asInstant","Date","parse","NaN","readVersion","body","raw","v","version","parseInt","isInteger","NotificationError","DIAGNOSTIC_CODES","PAYLOAD_MALFORMED","received","readKind","kind","has","readId","id","length","readContent","content","title","subtitle","readMoment","moment","at","anchoring","normalizeEnvelope","receivedAt","record","data","versionSkew","envelope","ownerTag","tone","routing","dedupId"],"sourceRoot":"../../../src","sources":["push/envelope.ts"],"mappings":";;;;;;;AAmBA,IAAAA,OAAA,GAAAC,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACO,MAAMC,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,CAAC;AAE5C,MAAME,KAAK,GAAG,IAAIC,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAEhE,SAASC,QAAQA,CAACC,KAAc,EAAuC;EACtE,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,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|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFcmProvider = createFcmProvider;
|
|
7
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
8
|
+
/**
|
|
9
|
+
* The Firebase Cloud Messaging provider.
|
|
10
|
+
*
|
|
11
|
+
* Every `@react-native-firebase/messaging` import is confined to this file, so
|
|
12
|
+
* the rest of the package — and every consuming app — stays free of provider
|
|
13
|
+
* types. Substituting a provider is an adapter swap, not a rewrite.
|
|
14
|
+
*
|
|
15
|
+
* The module is required **lazily**. That matters more here than for the
|
|
16
|
+
* engine: messaging is an *optional* peer dependency, and an app that never
|
|
17
|
+
* enables push must not fail at import time for a package it deliberately did
|
|
18
|
+
* not install.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Minimal shape used from the SDK, so its full surface never leaks into typing. */
|
|
22
|
+
|
|
23
|
+
const messagingPeer = (0, _rnCore.lazyPeer)('@react-native-firebase/messaging', () => {
|
|
24
|
+
// Inside `try`, so Metro bundles an app that leaves this optional peer out.
|
|
25
|
+
try {
|
|
26
|
+
return require('@react-native-firebase/messaging');
|
|
27
|
+
} catch (cause) {
|
|
28
|
+
throw cause;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function loadMessaging() {
|
|
32
|
+
// Absent optional peer, or missing native module: reported as unavailability
|
|
33
|
+
// through the normal path rather than thrown at import.
|
|
34
|
+
const result = messagingPeer.get();
|
|
35
|
+
return result.ok ? result.module.default : undefined;
|
|
36
|
+
}
|
|
37
|
+
function createFcmProvider(options = {}) {
|
|
38
|
+
let cached = options.module;
|
|
39
|
+
let resolved = options.module !== undefined;
|
|
40
|
+
const messaging = () => {
|
|
41
|
+
if (!resolved) {
|
|
42
|
+
cached = loadMessaging();
|
|
43
|
+
resolved = true;
|
|
44
|
+
}
|
|
45
|
+
return cached?.();
|
|
46
|
+
};
|
|
47
|
+
if (options.onBackgroundMessage !== undefined) {
|
|
48
|
+
messaging()?.setBackgroundMessageHandler(options.onBackgroundMessage);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
name: '@react-native-firebase/messaging',
|
|
52
|
+
async getAvailability() {
|
|
53
|
+
const instance = messaging();
|
|
54
|
+
|
|
55
|
+
// A device without Google Play Services, or an app that never installed
|
|
56
|
+
// the optional peer. Either way the local path is unaffected.
|
|
57
|
+
if (instance === undefined) return 'unavailable';
|
|
58
|
+
|
|
59
|
+
// Asked without registering: fetching a token here would create an FCM
|
|
60
|
+
// registration (and an APNs one on iOS) just to answer a yes-or-no
|
|
61
|
+
// question, before the app asked for permission (NOT-24).
|
|
62
|
+
try {
|
|
63
|
+
if (instance.isDeviceRegisteredForRemoteMessages === true) {
|
|
64
|
+
return 'available';
|
|
65
|
+
}
|
|
66
|
+
if (instance.hasPermission !== undefined) {
|
|
67
|
+
// Messaging is present; whether it may deliver is the permission's
|
|
68
|
+
// question, and that is answered without registering anything.
|
|
69
|
+
await instance.hasPermission();
|
|
70
|
+
return 'available';
|
|
71
|
+
}
|
|
72
|
+
return 'unknown';
|
|
73
|
+
} catch {
|
|
74
|
+
// The SDK does not say why, so `unknown` rather than a guess.
|
|
75
|
+
return 'unknown';
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
async getToken() {
|
|
79
|
+
const instance = messaging();
|
|
80
|
+
if (instance === undefined) {
|
|
81
|
+
throw new Error('Push provider is unavailable on this device.');
|
|
82
|
+
}
|
|
83
|
+
// Resolves only once a genuine token exists; the gate never presents an
|
|
84
|
+
// empty value as if it were one.
|
|
85
|
+
return instance.getToken();
|
|
86
|
+
},
|
|
87
|
+
onTokenChange(handler) {
|
|
88
|
+
const instance = messaging();
|
|
89
|
+
if (instance === undefined) return () => undefined;
|
|
90
|
+
return instance.onTokenRefresh(handler);
|
|
91
|
+
},
|
|
92
|
+
async invalidateToken() {
|
|
93
|
+
const instance = messaging();
|
|
94
|
+
if (instance === undefined) return false;
|
|
95
|
+
try {
|
|
96
|
+
await instance.deleteToken();
|
|
97
|
+
return true;
|
|
98
|
+
} catch {
|
|
99
|
+
// Reported as a failed invalidation rather than assumed successful —
|
|
100
|
+
// the device may keep receiving the previous account's messages.
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
subscribeToMessages(handler) {
|
|
105
|
+
const instance = messaging();
|
|
106
|
+
if (instance === undefined) return () => undefined;
|
|
107
|
+
|
|
108
|
+
// Foreground only. Background delivery arrives through the handler the
|
|
109
|
+
// consumer registers at module scope, which the README documents.
|
|
110
|
+
return instance.onMessage(message => {
|
|
111
|
+
handler(message);
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
async takeInitialMessage() {
|
|
115
|
+
const instance = messaging();
|
|
116
|
+
if (instance === undefined) return undefined;
|
|
117
|
+
const message = await instance.getInitialNotification();
|
|
118
|
+
return message ?? undefined;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=fcm-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","messagingPeer","lazyPeer","cause","loadMessaging","result","get","ok","module","default","undefined","createFcmProvider","options","cached","resolved","messaging","onBackgroundMessage","setBackgroundMessageHandler","name","getAvailability","instance","isDeviceRegisteredForRemoteMessages","hasPermission","getToken","Error","onTokenChange","handler","onTokenRefresh","invalidateToken","deleteToken","subscribeToMessages","onMessage","message","takeInitialMessage","getInitialNotification"],"sourceRoot":"../../../src","sources":["push/fcm-provider.ts"],"mappings":";;;;;;AAaA,IAAAA,OAAA,GAAAC,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAiBA,MAAMC,aAAa,GAAG,IAAAC,gBAAQ,EAAC,kCAAkC,EAAE,MAAM;EACxE;EACA,IAAI;IACH,OAAOF,OAAO,CAAC,kCAAkC,CAAC;EACnD,CAAC,CAAC,OAAOG,KAAK,EAAE;IACf,MAAMA,KAAK;EACZ;AACD,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