@lifeready/core 1.0.0 → 1.0.1
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/README.md +62 -62
- package/karma.conf.js +32 -0
- package/ng-package.json +26 -0
- package/package.json +21 -29
- package/src/lib/_common/ast.ts +75 -0
- package/src/lib/_common/deferred-promise.ts +35 -0
- package/src/lib/_common/exceptions.ts +189 -0
- package/src/lib/_common/queries.gql.ts +200 -0
- package/src/lib/_common/run-outside-angular.ts +125 -0
- package/src/lib/_common/tests.ts +82 -0
- package/{lib/_common/types.d.ts → src/lib/_common/types.ts} +13 -10
- package/src/lib/_common/utils.ts +57 -0
- package/src/lib/api/api-mutation.spec.ts +547 -0
- package/src/lib/api/api-query.spec.ts +40 -0
- package/src/lib/api/contact-card.gql.ts +85 -0
- package/src/lib/api/contact-card.service.spec.ts +249 -0
- package/src/lib/api/contact-card.service.ts +228 -0
- package/src/lib/api/contact-card2.gql.ts +93 -0
- package/src/lib/api/contact-card2.service.spec.ts +297 -0
- package/src/lib/api/contact-card2.service.ts +139 -0
- package/src/lib/api/file.service.spec.ts +14 -0
- package/src/lib/api/file.service.ts +81 -0
- package/src/lib/api/item2.gql.ts +211 -0
- package/src/lib/api/item2.service.spec.ts +1043 -0
- package/src/lib/api/item2.service.ts +481 -0
- package/src/lib/api/key-exchange.gql.ts +196 -0
- package/src/lib/api/key-exchange.service.spec.ts +470 -0
- package/src/lib/api/key-exchange.service.ts +731 -0
- package/src/lib/api/key-exchange.types.ts +235 -0
- package/src/lib/api/key-exchange2.gql.ts +310 -0
- package/src/lib/api/key-exchange2.service.spec.ts +892 -0
- package/src/lib/api/key-exchange2.service.ts +875 -0
- package/src/lib/api/lock.gql.ts +67 -0
- package/src/lib/api/lock.service.spec.ts +549 -0
- package/src/lib/api/lock.service.ts +57 -0
- package/src/lib/api/lr-apollo.service.spec.ts +27 -0
- package/src/lib/api/lr-apollo.service.ts +43 -0
- package/{lib/api/lr-graphql/index.d.ts → src/lib/api/lr-graphql/index.ts} +5 -5
- package/src/lib/api/lr-graphql/lr-graphql.service.ts +313 -0
- package/src/lib/api/lr-graphql/lr-merged-mutation.ts +377 -0
- package/src/lib/api/lr-graphql/lr-mutation-base.ts +67 -0
- package/src/lib/api/lr-graphql/lr-mutation.ts +74 -0
- package/src/lib/api/lr-graphql/lr.service.ts +28 -0
- package/src/lib/api/message.service.spec.ts +20 -0
- package/src/lib/api/message.service.ts +210 -0
- package/src/lib/api/persist.service.spec.ts +209 -0
- package/src/lib/api/persist.service.ts +220 -0
- package/src/lib/api/query-processor/common-processors.service.ts +148 -0
- package/{lib/api/query-processor/index.d.ts → src/lib/api/query-processor/index.ts} +2 -2
- package/src/lib/api/query-processor/query-processor.service.ts +240 -0
- package/src/lib/api/query-processor/tp-password-reset-processor.service.ts +177 -0
- package/src/lib/api/shared-contact-card.service.ts +156 -0
- package/src/lib/api/shared-contact-card2.gql.ts +76 -0
- package/src/lib/api/shared-contact-card2.service.ts +154 -0
- package/src/lib/api/time.service.spec.ts +48 -0
- package/src/lib/api/time.service.ts +155 -0
- package/src/lib/api/types/graphql.types.ts +48 -0
- package/{lib/api/types/index.d.ts → src/lib/api/types/index.ts} +2 -2
- package/src/lib/api/types/lr-graphql.types.ts +467 -0
- package/src/lib/auth/auth.config.ts +83 -0
- package/src/lib/auth/auth.gql.ts +62 -0
- package/src/lib/auth/auth.types.ts +79 -0
- package/src/lib/auth/idle.service.spec.ts +119 -0
- package/src/lib/auth/idle.service.ts +208 -0
- package/src/lib/auth/idle.types.ts +11 -0
- package/src/lib/auth/lbop.service.spec.ts +56 -0
- package/src/lib/auth/lbop.service.ts +539 -0
- package/src/lib/auth/life-ready-auth.service.spec.ts +70 -0
- package/src/lib/auth/life-ready-auth.service.ts +454 -0
- package/src/lib/auth/password.service.spec.ts +51 -0
- package/src/lib/auth/password.service.ts +438 -0
- package/src/lib/auth/register.service.spec.ts +31 -0
- package/src/lib/auth/register.service.ts +181 -0
- package/src/lib/auth/two-factor.service.spec.ts +21 -0
- package/src/lib/auth/two-factor.service.ts +69 -0
- package/src/lib/category/category-meta.service.spec.ts +28 -0
- package/src/lib/category/category-meta.service.ts +125 -0
- package/src/lib/category/category.gql.ts +449 -0
- package/src/lib/category/category.service.spec.ts +26 -0
- package/src/lib/category/category.service.ts +498 -0
- package/src/lib/category/category.types.ts +89 -0
- package/src/lib/cryptography/cryptography.types.ts +108 -0
- package/src/lib/cryptography/encryption.service.spec.ts +125 -0
- package/src/lib/cryptography/encryption.service.ts +243 -0
- package/src/lib/cryptography/key-factory.service.spec.ts +15 -0
- package/src/lib/cryptography/key-factory.service.ts +303 -0
- package/src/lib/cryptography/key-graph.service.spec.ts +16 -0
- package/src/lib/cryptography/key-graph.service.ts +354 -0
- package/src/lib/cryptography/key-meta.service.spec.ts +40 -0
- package/src/lib/cryptography/key-meta.service.ts +254 -0
- package/src/lib/cryptography/key.service.spec.ts +16 -0
- package/src/lib/cryptography/key.service.ts +154 -0
- package/src/lib/cryptography/slip39.service.spec.ts +44 -0
- package/src/lib/cryptography/slip39.service.ts +204 -0
- package/src/lib/cryptography/web-crypto.service.ts +22 -0
- package/src/lib/life-ready.config.ts +127 -0
- package/src/lib/life-ready.module.ts +81 -0
- package/src/lib/plan/plan.gql.ts +133 -0
- package/src/lib/plan/plan.service.spec.ts +294 -0
- package/src/lib/plan/plan.service.ts +198 -0
- package/src/lib/plan/plan.types.ts +37 -0
- package/src/lib/record/record-attachment.service.spec.ts +31 -0
- package/src/lib/record/record-attachment.service.ts +101 -0
- package/src/lib/record/record.gql.ts +192 -0
- package/src/lib/record/record.service.spec.ts +598 -0
- package/src/lib/record/record.service.ts +236 -0
- package/src/lib/record/record.types.ts +86 -0
- package/src/lib/record-type/record-type.service.spec.ts +16 -0
- package/src/lib/record-type/record-type.service.ts +71 -0
- package/src/lib/record-type/record-type.types.ts +58 -0
- package/src/lib/scenario/approvals/scenario-approval.gql.ts +112 -0
- package/src/lib/scenario/approvals/scenario-approval.types.ts +85 -0
- package/src/lib/scenario/approvals/scenario-approver.service.spec.ts +16 -0
- package/src/lib/scenario/approvals/scenario-approver.service.ts +422 -0
- package/src/lib/scenario/claimants/scenario-claimant.gql.ts +56 -0
- package/src/lib/scenario/claimants/scenario-claimant.service.spec.ts +16 -0
- package/src/lib/scenario/claimants/scenario-claimant.service.ts +100 -0
- package/src/lib/scenario/claimants/scenario-claimant.types.ts +21 -0
- package/src/lib/scenario/receivers/scenario-receiver.gql.ts +157 -0
- package/src/lib/scenario/receivers/scenario-receiver.service.spec.ts +16 -0
- package/src/lib/scenario/receivers/scenario-receiver.service.ts +278 -0
- package/src/lib/scenario/receivers/scenario-receiver.types.ts +66 -0
- package/src/lib/scenario/scenario-setup.service.spec.ts +22 -0
- package/src/lib/scenario/scenario-setup.service.ts +369 -0
- package/src/lib/scenario/scenario.gql.ts +404 -0
- package/src/lib/scenario/scenario.service.spec.ts +1586 -0
- package/src/lib/scenario/scenario.service.ts +811 -0
- package/src/lib/scenario/scenario.types.ts +258 -0
- package/src/lib/search/search.gql.ts +62 -0
- package/src/lib/search/search.service.spec.ts +57 -0
- package/src/lib/search/search.service.ts +174 -0
- package/src/lib/search/search.types.ts +24 -0
- package/src/lib/trusted-parties/tp-password-reset-request.service.ts +140 -0
- package/src/lib/trusted-parties/tp-password-reset-user.service.ts +359 -0
- package/src/lib/trusted-parties/tp-password-reset.gql.ts +453 -0
- package/src/lib/trusted-parties/tp-password-reset.service.spec.ts +602 -0
- package/src/lib/trusted-parties/tp-password-reset.service.ts +482 -0
- package/src/lib/trusted-parties/trusted-party.gql.ts +159 -0
- package/src/lib/trusted-parties/trusted-party.service.spec.ts +1008 -0
- package/src/lib/trusted-parties/trusted-party.service.ts +394 -0
- package/src/lib/trusted-parties/trusted-party.types.ts +119 -0
- package/src/lib/trusted-parties/trusted-party2.gql.ts +165 -0
- package/src/lib/trusted-parties/trusted-party2.service.spec.ts +1782 -0
- package/src/lib/trusted-parties/trusted-party2.service.ts +272 -0
- package/src/lib/users/profile-details.service.spec.ts +45 -0
- package/src/lib/users/profile-details.service.ts +278 -0
- package/src/lib/users/profile.gql.ts +108 -0
- package/src/lib/users/profile.service.spec.ts +97 -0
- package/src/lib/users/profile.service.ts +224 -0
- package/src/lib/users/profile.types.ts +101 -0
- package/src/lib/users/user.gql.ts +69 -0
- package/src/lib/users/user.service.spec.ts +161 -0
- package/src/lib/users/user.service.ts +72 -0
- package/src/lib/users/user.types.ts +27 -0
- package/{public-api.d.ts → src/public-api.ts} +96 -77
- package/src/test.ts +21 -0
- package/tsconfig.lib.json +21 -0
- package/tsconfig.lib.prod.json +6 -0
- package/tsconfig.spec.json +10 -0
- package/tslint.json +17 -0
- package/bundles/lifeready-core.umd.js +0 -15876
- package/bundles/lifeready-core.umd.js.map +0 -1
- package/bundles/lifeready-core.umd.min.js +0 -16
- package/bundles/lifeready-core.umd.min.js.map +0 -1
- package/esm2015/lib/_common/ast.js +0 -40
- package/esm2015/lib/_common/deferred-promise.js +0 -24
- package/esm2015/lib/_common/exceptions.js +0 -157
- package/esm2015/lib/_common/queries.gql.js +0 -190
- package/esm2015/lib/_common/run-outside-angular.js +0 -79
- package/esm2015/lib/_common/types.js +0 -1
- package/esm2015/lib/_common/utils.js +0 -44
- package/esm2015/lib/api/contact-card.gql.js +0 -79
- package/esm2015/lib/api/contact-card.service.js +0 -154
- package/esm2015/lib/api/contact-card2.gql.js +0 -60
- package/esm2015/lib/api/contact-card2.service.js +0 -103
- package/esm2015/lib/api/file.service.js +0 -74
- package/esm2015/lib/api/item2.gql.js +0 -110
- package/esm2015/lib/api/item2.service.js +0 -311
- package/esm2015/lib/api/key-exchange.gql.js +0 -188
- package/esm2015/lib/api/key-exchange.service.js +0 -442
- package/esm2015/lib/api/key-exchange.types.js +0 -18
- package/esm2015/lib/api/key-exchange2.gql.js +0 -171
- package/esm2015/lib/api/key-exchange2.service.js +0 -479
- package/esm2015/lib/api/lock.gql.js +0 -40
- package/esm2015/lib/api/lock.service.js +0 -64
- package/esm2015/lib/api/lr-apollo.service.js +0 -46
- package/esm2015/lib/api/lr-graphql/index.js +0 -6
- package/esm2015/lib/api/lr-graphql/lr-graphql.service.js +0 -155
- package/esm2015/lib/api/lr-graphql/lr-merged-mutation.js +0 -213
- package/esm2015/lib/api/lr-graphql/lr-mutation-base.js +0 -51
- package/esm2015/lib/api/lr-graphql/lr-mutation.js +0 -48
- package/esm2015/lib/api/lr-graphql/lr.service.js +0 -18
- package/esm2015/lib/api/message.service.js +0 -138
- package/esm2015/lib/api/persist.service.js +0 -181
- package/esm2015/lib/api/query-processor/common-processors.service.js +0 -93
- package/esm2015/lib/api/query-processor/index.js +0 -3
- package/esm2015/lib/api/query-processor/query-processor.service.js +0 -192
- package/esm2015/lib/api/query-processor/tp-password-reset-processor.service.js +0 -109
- package/esm2015/lib/api/shared-contact-card.service.js +0 -119
- package/esm2015/lib/api/shared-contact-card2.gql.js +0 -41
- package/esm2015/lib/api/shared-contact-card2.service.js +0 -117
- package/esm2015/lib/api/time.service.js +0 -146
- package/esm2015/lib/api/types/graphql.types.js +0 -7
- package/esm2015/lib/api/types/index.js +0 -3
- package/esm2015/lib/api/types/lr-graphql.types.js +0 -71
- package/esm2015/lib/auth/auth.config.js +0 -57
- package/esm2015/lib/auth/auth.gql.js +0 -48
- package/esm2015/lib/auth/auth.types.js +0 -27
- package/esm2015/lib/auth/idle.service.js +0 -168
- package/esm2015/lib/auth/idle.types.js +0 -7
- package/esm2015/lib/auth/lbop.service.js +0 -355
- package/esm2015/lib/auth/life-ready-auth.service.js +0 -333
- package/esm2015/lib/auth/password.service.js +0 -320
- package/esm2015/lib/auth/register.service.js +0 -172
- package/esm2015/lib/auth/two-factor.service.js +0 -74
- package/esm2015/lib/category/category-meta.service.js +0 -99
- package/esm2015/lib/category/category.gql.js +0 -406
- package/esm2015/lib/category/category.service.js +0 -390
- package/esm2015/lib/category/category.types.js +0 -29
- package/esm2015/lib/cryptography/cryptography.types.js +0 -11
- package/esm2015/lib/cryptography/encryption.service.js +0 -189
- package/esm2015/lib/cryptography/key-factory.service.js +0 -237
- package/esm2015/lib/cryptography/key-graph.service.js +0 -280
- package/esm2015/lib/cryptography/key-meta.service.js +0 -200
- package/esm2015/lib/cryptography/key.service.js +0 -124
- package/esm2015/lib/cryptography/slip39.service.js +0 -169
- package/esm2015/lib/cryptography/web-crypto.service.js +0 -29
- package/esm2015/lib/life-ready.config.js +0 -84
- package/esm2015/lib/life-ready.module.js +0 -74
- package/esm2015/lib/plan/plan.gql.js +0 -123
- package/esm2015/lib/plan/plan.service.js +0 -149
- package/esm2015/lib/plan/plan.types.js +0 -11
- package/esm2015/lib/record/record-attachment.service.js +0 -101
- package/esm2015/lib/record/record.gql.js +0 -179
- package/esm2015/lib/record/record.service.js +0 -206
- package/esm2015/lib/record/record.types.js +0 -15
- package/esm2015/lib/record-type/record-type.service.js +0 -75
- package/esm2015/lib/record-type/record-type.types.js +0 -28
- package/esm2015/lib/scenario/approvals/scenario-approval.gql.js +0 -105
- package/esm2015/lib/scenario/approvals/scenario-approval.types.js +0 -1
- package/esm2015/lib/scenario/approvals/scenario-approver.service.js +0 -300
- package/esm2015/lib/scenario/claimants/scenario-claimant.gql.js +0 -52
- package/esm2015/lib/scenario/claimants/scenario-claimant.service.js +0 -97
- package/esm2015/lib/scenario/claimants/scenario-claimant.types.js +0 -1
- package/esm2015/lib/scenario/receivers/scenario-receiver.gql.js +0 -150
- package/esm2015/lib/scenario/receivers/scenario-receiver.service.js +0 -229
- package/esm2015/lib/scenario/receivers/scenario-receiver.types.js +0 -1
- package/esm2015/lib/scenario/scenario-setup.service.js +0 -269
- package/esm2015/lib/scenario/scenario.gql.js +0 -368
- package/esm2015/lib/scenario/scenario.service.js +0 -611
- package/esm2015/lib/scenario/scenario.types.js +0 -64
- package/esm2015/lib/search/search.gql.js +0 -62
- package/esm2015/lib/search/search.service.js +0 -156
- package/esm2015/lib/search/search.types.js +0 -6
- package/esm2015/lib/trusted-parties/tp-password-reset-request.service.js +0 -112
- package/esm2015/lib/trusted-parties/tp-password-reset-user.service.js +0 -266
- package/esm2015/lib/trusted-parties/tp-password-reset.gql.js +0 -232
- package/esm2015/lib/trusted-parties/tp-password-reset.service.js +0 -300
- package/esm2015/lib/trusted-parties/trusted-party.gql.js +0 -148
- package/esm2015/lib/trusted-parties/trusted-party.service.js +0 -326
- package/esm2015/lib/trusted-parties/trusted-party.types.js +0 -41
- package/esm2015/lib/trusted-parties/trusted-party2.gql.js +0 -87
- package/esm2015/lib/trusted-parties/trusted-party2.service.js +0 -215
- package/esm2015/lib/users/profile-details.service.js +0 -214
- package/esm2015/lib/users/profile.gql.js +0 -97
- package/esm2015/lib/users/profile.service.js +0 -169
- package/esm2015/lib/users/profile.types.js +0 -34
- package/esm2015/lib/users/user.gql.js +0 -60
- package/esm2015/lib/users/user.service.js +0 -79
- package/esm2015/lib/users/user.types.js +0 -5
- package/esm2015/lifeready-core.js +0 -10
- package/esm2015/public-api.js +0 -81
- package/fesm2015/lifeready-core.js +0 -13282
- package/fesm2015/lifeready-core.js.map +0 -1
- package/lib/_common/ast.d.ts +0 -11
- package/lib/_common/deferred-promise.d.ts +0 -12
- package/lib/_common/exceptions.d.ts +0 -109
- package/lib/_common/queries.gql.d.ts +0 -10
- package/lib/_common/run-outside-angular.d.ts +0 -14
- package/lib/_common/utils.d.ts +0 -3
- package/lib/api/contact-card.gql.d.ts +0 -7
- package/lib/api/contact-card.service.d.ts +0 -52
- package/lib/api/contact-card2.gql.d.ts +0 -34
- package/lib/api/contact-card2.service.d.ts +0 -49
- package/lib/api/file.service.d.ts +0 -18
- package/lib/api/item2.gql.d.ts +0 -96
- package/lib/api/item2.service.d.ts +0 -177
- package/lib/api/key-exchange.gql.d.ts +0 -9
- package/lib/api/key-exchange.service.d.ts +0 -39
- package/lib/api/key-exchange.types.d.ts +0 -196
- package/lib/api/key-exchange2.gql.d.ts +0 -125
- package/lib/api/key-exchange2.service.d.ts +0 -187
- package/lib/api/lock.gql.d.ts +0 -27
- package/lib/api/lock.service.d.ts +0 -25
- package/lib/api/lr-apollo.service.d.ts +0 -15
- package/lib/api/lr-graphql/lr-graphql.service.d.ts +0 -60
- package/lib/api/lr-graphql/lr-merged-mutation.d.ts +0 -27
- package/lib/api/lr-graphql/lr-mutation-base.d.ts +0 -28
- package/lib/api/lr-graphql/lr-mutation.d.ts +0 -8
- package/lib/api/lr-graphql/lr.service.d.ts +0 -9
- package/lib/api/message.service.d.ts +0 -58
- package/lib/api/persist.service.d.ts +0 -31
- package/lib/api/query-processor/common-processors.service.d.ts +0 -36
- package/lib/api/query-processor/query-processor.service.d.ts +0 -18
- package/lib/api/query-processor/tp-password-reset-processor.service.d.ts +0 -15
- package/lib/api/shared-contact-card.service.d.ts +0 -33
- package/lib/api/shared-contact-card2.gql.d.ts +0 -36
- package/lib/api/shared-contact-card2.service.d.ts +0 -45
- package/lib/api/time.service.d.ts +0 -16
- package/lib/api/types/graphql.types.d.ts +0 -29
- package/lib/api/types/lr-graphql.types.d.ts +0 -385
- package/lib/auth/auth.config.d.ts +0 -5
- package/lib/auth/auth.gql.d.ts +0 -15
- package/lib/auth/auth.types.d.ts +0 -66
- package/lib/auth/idle.service.d.ts +0 -40
- package/lib/auth/idle.types.d.ts +0 -10
- package/lib/auth/lbop.service.d.ts +0 -91
- package/lib/auth/life-ready-auth.service.d.ts +0 -46
- package/lib/auth/password.service.d.ts +0 -78
- package/lib/auth/register.service.d.ts +0 -25
- package/lib/auth/two-factor.service.d.ts +0 -15
- package/lib/category/category-meta.service.d.ts +0 -23
- package/lib/category/category.gql.d.ts +0 -45
- package/lib/category/category.service.d.ts +0 -67
- package/lib/category/category.types.d.ts +0 -79
- package/lib/cryptography/cryptography.types.d.ts +0 -83
- package/lib/cryptography/encryption.service.d.ts +0 -41
- package/lib/cryptography/key-factory.service.d.ts +0 -38
- package/lib/cryptography/key-graph.service.d.ts +0 -33
- package/lib/cryptography/key-meta.service.d.ts +0 -44
- package/lib/cryptography/key.service.d.ts +0 -36
- package/lib/cryptography/slip39.service.d.ts +0 -43
- package/lib/cryptography/web-crypto.service.d.ts +0 -5
- package/lib/life-ready.config.d.ts +0 -14
- package/lib/life-ready.module.d.ts +0 -5
- package/lib/plan/plan.gql.d.ts +0 -11
- package/lib/plan/plan.service.d.ts +0 -33
- package/lib/plan/plan.types.d.ts +0 -31
- package/lib/record/record-attachment.service.d.ts +0 -16
- package/lib/record/record.gql.d.ts +0 -14
- package/lib/record/record.service.d.ts +0 -25
- package/lib/record/record.types.d.ts +0 -57
- package/lib/record-type/record-type.service.d.ts +0 -11
- package/lib/record-type/record-type.types.d.ts +0 -50
- package/lib/scenario/approvals/scenario-approval.gql.d.ts +0 -7
- package/lib/scenario/approvals/scenario-approval.types.d.ts +0 -63
- package/lib/scenario/approvals/scenario-approver.service.d.ts +0 -32
- package/lib/scenario/claimants/scenario-claimant.gql.d.ts +0 -5
- package/lib/scenario/claimants/scenario-claimant.service.d.ts +0 -17
- package/lib/scenario/claimants/scenario-claimant.types.d.ts +0 -18
- package/lib/scenario/receivers/scenario-receiver.gql.d.ts +0 -8
- package/lib/scenario/receivers/scenario-receiver.service.d.ts +0 -30
- package/lib/scenario/receivers/scenario-receiver.types.d.ts +0 -54
- package/lib/scenario/scenario-setup.service.d.ts +0 -22
- package/lib/scenario/scenario.gql.d.ts +0 -34
- package/lib/scenario/scenario.service.d.ts +0 -58
- package/lib/scenario/scenario.types.d.ts +0 -217
- package/lib/search/search.gql.d.ts +0 -1
- package/lib/search/search.service.d.ts +0 -25
- package/lib/search/search.types.d.ts +0 -20
- package/lib/trusted-parties/tp-password-reset-request.service.d.ts +0 -20
- package/lib/trusted-parties/tp-password-reset-user.service.d.ts +0 -41
- package/lib/trusted-parties/tp-password-reset.gql.d.ts +0 -218
- package/lib/trusted-parties/tp-password-reset.service.d.ts +0 -131
- package/lib/trusted-parties/trusted-party.gql.d.ts +0 -9
- package/lib/trusted-parties/trusted-party.service.d.ts +0 -44
- package/lib/trusted-parties/trusted-party.types.d.ts +0 -102
- package/lib/trusted-parties/trusted-party2.gql.d.ts +0 -79
- package/lib/trusted-parties/trusted-party2.service.d.ts +0 -114
- package/lib/users/profile-details.service.d.ts +0 -21
- package/lib/users/profile.gql.d.ts +0 -11
- package/lib/users/profile.service.d.ts +0 -35
- package/lib/users/profile.types.d.ts +0 -96
- package/lib/users/user.gql.d.ts +0 -9
- package/lib/users/user.service.d.ts +0 -12
- package/lib/users/user.types.d.ts +0 -23
- package/lifeready-core.d.ts +0 -9
- package/lifeready-core.metadata.json +0 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import gql from 'graphql-tag';
|
|
2
|
+
|
|
3
|
+
export const CreateStripeCheckoutSessionMutation = gql`
|
|
4
|
+
mutation CreateStripeCheckoutSession(
|
|
5
|
+
$priceId: String!
|
|
6
|
+
$successUrl: String!
|
|
7
|
+
$cancelUrl: String!
|
|
8
|
+
) {
|
|
9
|
+
createStripeCheckoutSession(
|
|
10
|
+
input: {
|
|
11
|
+
priceId: $priceId
|
|
12
|
+
successUrl: $successUrl
|
|
13
|
+
cancelUrl: $cancelUrl
|
|
14
|
+
}
|
|
15
|
+
) {
|
|
16
|
+
sessionId
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export const CreateStripeBillingPortalSessionMutation = gql`
|
|
22
|
+
mutation CreateStripeBillingPortalSession($returnUrl: String!) {
|
|
23
|
+
createStripeBillingPortalSession(input: { returnUrl: $returnUrl }) {
|
|
24
|
+
sessionUrl
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export const planFields = `
|
|
30
|
+
name
|
|
31
|
+
data
|
|
32
|
+
state
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export const CreateUserIssuedPlanMutation = gql`
|
|
36
|
+
mutation CreateUserIssuedPlan($input: CreateUserIssuedPlanInput!){
|
|
37
|
+
createUserIssuedPlan(input: $input) {
|
|
38
|
+
userIssuedPlan {
|
|
39
|
+
id
|
|
40
|
+
plan {
|
|
41
|
+
${planFields}
|
|
42
|
+
}
|
|
43
|
+
token
|
|
44
|
+
tokenExpiryTime
|
|
45
|
+
planPeriodEnd
|
|
46
|
+
planPeriodEndAfterSeconds
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}`;
|
|
50
|
+
|
|
51
|
+
export const DeleteUserIssuedPlanMutation = gql`
|
|
52
|
+
mutation DeleteUserIssuedPlan($input: DeleteUserIssuedPlanInput!) {
|
|
53
|
+
deleteUserIssuedPlan(input: $input) {
|
|
54
|
+
id
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
export const UserIssuablePlansQuery = gql`
|
|
60
|
+
query UserIssuablePlans {
|
|
61
|
+
userIssuablePlans {
|
|
62
|
+
plan {
|
|
63
|
+
${planFields}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
// Put other fields in as needed.
|
|
70
|
+
export const UserIssuedPlansQuery = gql`
|
|
71
|
+
query UserIssuedPlans {
|
|
72
|
+
userIssuedPlans {
|
|
73
|
+
edges {
|
|
74
|
+
node {
|
|
75
|
+
id
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
export const UserIssuedPlanQuery = gql`
|
|
83
|
+
query UserIssuedPlan(
|
|
84
|
+
$id: LrRelayIdInput!
|
|
85
|
+
$token: String
|
|
86
|
+
) {
|
|
87
|
+
userIssuedPlan(
|
|
88
|
+
id: $id
|
|
89
|
+
token: $token
|
|
90
|
+
) {
|
|
91
|
+
id
|
|
92
|
+
plan {
|
|
93
|
+
${planFields}
|
|
94
|
+
}
|
|
95
|
+
planPeriodEnd
|
|
96
|
+
planPeriodEndAfterSeconds
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
export const AssociateUserIssuedPlanMutation = gql`
|
|
102
|
+
mutation AssociateUserIssuedPlan($input: AssociateUserIssuedPlanInput!){
|
|
103
|
+
associateUserIssuedPlan(input: $input) {
|
|
104
|
+
userPlan {
|
|
105
|
+
id
|
|
106
|
+
plan {
|
|
107
|
+
${planFields}
|
|
108
|
+
}
|
|
109
|
+
periodEnd
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}`;
|
|
113
|
+
|
|
114
|
+
export const UserPlansQuery = gql`
|
|
115
|
+
query UserPlans {
|
|
116
|
+
userPlans {
|
|
117
|
+
id
|
|
118
|
+
periodEnd
|
|
119
|
+
plan {
|
|
120
|
+
${planFields}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
export const StripeQuery = gql`
|
|
127
|
+
query Stripe {
|
|
128
|
+
stripe {
|
|
129
|
+
id
|
|
130
|
+
customer
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { TestBed, async } from '@angular/core/testing';
|
|
2
|
+
import {
|
|
3
|
+
lrConfigureTestingModule,
|
|
4
|
+
lrExpectAsyncThrow,
|
|
5
|
+
lrit,
|
|
6
|
+
} from '../_common/tests';
|
|
7
|
+
import { PlanService } from './plan.service';
|
|
8
|
+
import gql from 'graphql-tag';
|
|
9
|
+
import { LrApolloService } from '../api/lr-apollo.service';
|
|
10
|
+
import {
|
|
11
|
+
loginTestUser,
|
|
12
|
+
logoutUser,
|
|
13
|
+
} from '../auth/life-ready-auth.service.spec';
|
|
14
|
+
import { LifeReadyAuthService } from '../auth/life-ready-auth.service';
|
|
15
|
+
import { environment } from 'projects/lr-auth-app/src/environments/environment';
|
|
16
|
+
import { FeatureAction } from '../auth/auth.types';
|
|
17
|
+
import { setupTps } from '../trusted-parties/trusted-party.service.spec';
|
|
18
|
+
import { TrustedPartyService } from '../trusted-parties/trusted-party.service';
|
|
19
|
+
|
|
20
|
+
const TIMEOUT = 1000 * 60 * 10;
|
|
21
|
+
|
|
22
|
+
const DebugCreateUserPlanMutation = gql`
|
|
23
|
+
mutation DebugCreateUserPlan($planName: String!, $periodEnd: DateTime) {
|
|
24
|
+
debugCreateUserPlan(input: { planName: $planName, periodEnd: $periodEnd }) {
|
|
25
|
+
userPlan {
|
|
26
|
+
id
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
const DebugDeletePlanMutation = gql`
|
|
33
|
+
mutation DebugDeleteUserPlan($id: LrRelayIdInput!) {
|
|
34
|
+
debugDeleteUserPlan(input: { id: $id }) {
|
|
35
|
+
id
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
describe('PlanService', () => {
|
|
41
|
+
let planService: PlanService;
|
|
42
|
+
let lrApollo: LrApolloService;
|
|
43
|
+
let authService: LifeReadyAuthService;
|
|
44
|
+
let tpService: TrustedPartyService;
|
|
45
|
+
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
lrConfigureTestingModule();
|
|
48
|
+
planService = TestBed.inject(PlanService);
|
|
49
|
+
lrApollo = TestBed.inject(LrApolloService);
|
|
50
|
+
authService = TestBed.inject(LifeReadyAuthService);
|
|
51
|
+
tpService = TestBed.inject(TrustedPartyService);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
enum PlanName {
|
|
55
|
+
DEBUG_ALLOW_ALL = 'debug_allow_all',
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function debugCreateUserPlan(
|
|
59
|
+
planName: PlanName,
|
|
60
|
+
periodEnd?: string // ISO string
|
|
61
|
+
): Promise<void> {
|
|
62
|
+
const res = await lrApollo.mutate<{ debugCreateUserPlan: any }>({
|
|
63
|
+
mutation: DebugCreateUserPlanMutation,
|
|
64
|
+
variables: {
|
|
65
|
+
planName,
|
|
66
|
+
periodEnd,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function debugDeleteUserPlan(id: string): Promise<void> {
|
|
72
|
+
const res = await lrApollo.mutate<{ debugDeleteUserPlan: any }>({
|
|
73
|
+
mutation: DebugDeletePlanMutation,
|
|
74
|
+
variables: {
|
|
75
|
+
id,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function futureDate(seconds) {
|
|
81
|
+
return new Date(Date.now() + 1000 * seconds);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function deleteAllIssuedPlans() {
|
|
85
|
+
const issuedPlans = await planService.getUserIssuedPlans();
|
|
86
|
+
await Promise.all(
|
|
87
|
+
issuedPlans.map((t) => planService.deleteUserIssuedPlan(t.id))
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function deleteAllUserPlans() {
|
|
92
|
+
const userPlans = await planService.getUserPlans();
|
|
93
|
+
await Promise.all(userPlans.map((t) => debugDeleteUserPlan(t.id)));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const {
|
|
97
|
+
username: username1,
|
|
98
|
+
password: password1,
|
|
99
|
+
} = environment.test.users[0];
|
|
100
|
+
const {
|
|
101
|
+
username: username2,
|
|
102
|
+
password: password2,
|
|
103
|
+
} = environment.test.users[1];
|
|
104
|
+
|
|
105
|
+
lrit('should be created', () => {
|
|
106
|
+
expect(planService).toBeTruthy();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
lrit(
|
|
110
|
+
'should get list of user issuable plans',
|
|
111
|
+
async () => {
|
|
112
|
+
const user1 = await loginTestUser(username1, password1);
|
|
113
|
+
|
|
114
|
+
const issuablePlans = await planService.getUserIssuablePlans();
|
|
115
|
+
expect(issuablePlans.length).toBe(1);
|
|
116
|
+
expect(issuablePlans[0].plan.name).toEqual(PlanName.DEBUG_ALLOW_ALL);
|
|
117
|
+
},
|
|
118
|
+
TIMEOUT
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
lrit(
|
|
122
|
+
'should issue plans',
|
|
123
|
+
async () => {
|
|
124
|
+
const user1 = await loginTestUser(username1, password1);
|
|
125
|
+
|
|
126
|
+
await deleteAllIssuedPlans();
|
|
127
|
+
|
|
128
|
+
const tokenExpiryTime = futureDate(15);
|
|
129
|
+
const planPeriodEnd = futureDate(1000);
|
|
130
|
+
|
|
131
|
+
const issuedPlan = await planService.createUserIssuedPlan({
|
|
132
|
+
planName: PlanName.DEBUG_ALLOW_ALL,
|
|
133
|
+
tokenExpiryTime,
|
|
134
|
+
planPeriodEnd,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
expect(issuedPlan.plan.name).toEqual(PlanName.DEBUG_ALLOW_ALL);
|
|
138
|
+
expect(issuedPlan.planPeriodEnd).toEqual(planPeriodEnd);
|
|
139
|
+
expect(issuedPlan.tokenExpiryTime).toEqual(tokenExpiryTime);
|
|
140
|
+
|
|
141
|
+
let issuedPlans = await planService.getUserIssuedPlans();
|
|
142
|
+
expect(issuedPlans.length).toBe(1);
|
|
143
|
+
|
|
144
|
+
await planService.deleteUserIssuedPlan(issuedPlan.id);
|
|
145
|
+
|
|
146
|
+
issuedPlans = await planService.getUserIssuedPlans();
|
|
147
|
+
expect(issuedPlans.length).toBe(0);
|
|
148
|
+
},
|
|
149
|
+
TIMEOUT
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
lrit(
|
|
153
|
+
'should get stripe issued plans',
|
|
154
|
+
async () => {
|
|
155
|
+
await loginTestUser(username1, password1);
|
|
156
|
+
await planService.getStripe();
|
|
157
|
+
},
|
|
158
|
+
TIMEOUT
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
lrit(
|
|
162
|
+
'should associate issued plans',
|
|
163
|
+
async () => {
|
|
164
|
+
await loginTestUser(username1, password1);
|
|
165
|
+
|
|
166
|
+
await deleteAllIssuedPlans();
|
|
167
|
+
|
|
168
|
+
const tokenExpiryTime = futureDate(15);
|
|
169
|
+
const planPeriodEnd = futureDate(1000);
|
|
170
|
+
|
|
171
|
+
const issuedPlan = await planService.createUserIssuedPlan({
|
|
172
|
+
planName: PlanName.DEBUG_ALLOW_ALL,
|
|
173
|
+
tokenExpiryTime,
|
|
174
|
+
planPeriodEnd,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Has access without the token
|
|
178
|
+
expect((await planService.getUserIssuedPlan(issuedPlan.id)).id).toEqual(
|
|
179
|
+
issuedPlan.id
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
await logoutUser();
|
|
183
|
+
|
|
184
|
+
// No access without the token
|
|
185
|
+
await lrExpectAsyncThrow(planService.getUserIssuedPlan(issuedPlan.id));
|
|
186
|
+
|
|
187
|
+
// Has access with the token
|
|
188
|
+
expect(
|
|
189
|
+
(await planService.getUserIssuedPlan(issuedPlan.id, issuedPlan.token))
|
|
190
|
+
.id
|
|
191
|
+
).toEqual(issuedPlan.id);
|
|
192
|
+
|
|
193
|
+
await loginTestUser(username2, password2);
|
|
194
|
+
await deleteAllUserPlans();
|
|
195
|
+
|
|
196
|
+
// No access without the token
|
|
197
|
+
await lrExpectAsyncThrow(planService.getUserIssuedPlan(issuedPlan.id));
|
|
198
|
+
|
|
199
|
+
// Has access with the token
|
|
200
|
+
expect(
|
|
201
|
+
(await planService.getUserIssuedPlan(issuedPlan.id, issuedPlan.token))
|
|
202
|
+
.id
|
|
203
|
+
).toEqual(issuedPlan.id);
|
|
204
|
+
|
|
205
|
+
await lrExpectAsyncThrow(
|
|
206
|
+
planService.associateUserIssuedPlan({
|
|
207
|
+
id: issuedPlan.id,
|
|
208
|
+
token: issuedPlan.token + '123',
|
|
209
|
+
})
|
|
210
|
+
);
|
|
211
|
+
await lrExpectAsyncThrow(
|
|
212
|
+
planService.associateUserIssuedPlan({
|
|
213
|
+
id: issuedPlan.id,
|
|
214
|
+
token: null,
|
|
215
|
+
})
|
|
216
|
+
);
|
|
217
|
+
await lrExpectAsyncThrow(
|
|
218
|
+
planService.associateUserIssuedPlan({
|
|
219
|
+
id: issuedPlan.id,
|
|
220
|
+
token: '',
|
|
221
|
+
})
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
const userPlan = await planService.associateUserIssuedPlan({
|
|
225
|
+
id: issuedPlan.id,
|
|
226
|
+
token: issuedPlan.token,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
expect(userPlan.plan.name).toBe(PlanName.DEBUG_ALLOW_ALL);
|
|
230
|
+
|
|
231
|
+
const userPlans = await planService.getUserPlans();
|
|
232
|
+
expect(userPlans.some((t) => t.id === userPlan.id)).toBeTrue();
|
|
233
|
+
|
|
234
|
+
await loginTestUser(username1, password1);
|
|
235
|
+
|
|
236
|
+
let issuedPlans = await planService.getUserIssuedPlans();
|
|
237
|
+
expect(issuedPlans.length).toBe(1);
|
|
238
|
+
expect(issuedPlans[0].id).toBe(issuedPlan.id);
|
|
239
|
+
|
|
240
|
+
// Deleting a UserIssuedPlan should also delete any associated UserPlans.
|
|
241
|
+
await loginTestUser(username1, password1);
|
|
242
|
+
await planService.deleteUserIssuedPlan(issuedPlan.id);
|
|
243
|
+
|
|
244
|
+
await loginTestUser(username2, password2);
|
|
245
|
+
issuedPlans = await planService.getUserIssuedPlans();
|
|
246
|
+
expect(issuedPlans.length).toBe(0);
|
|
247
|
+
},
|
|
248
|
+
TIMEOUT
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
lrit(
|
|
252
|
+
'should create user plans',
|
|
253
|
+
async () => {
|
|
254
|
+
let user1 = await loginTestUser(username1, password1);
|
|
255
|
+
// Remove all existing plans
|
|
256
|
+
await Promise.all(
|
|
257
|
+
user1.userPlans.map((userPlan) => debugDeleteUserPlan(userPlan.id))
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
// End in a few seconds
|
|
261
|
+
const endSeconds = 5;
|
|
262
|
+
const periodEnd = futureDate(endSeconds).toISOString();
|
|
263
|
+
|
|
264
|
+
await debugCreateUserPlan(PlanName.DEBUG_ALLOW_ALL, periodEnd);
|
|
265
|
+
|
|
266
|
+
user1 = await authService.getUser(true);
|
|
267
|
+
|
|
268
|
+
expect(user1.userPlans.length).toBe(1);
|
|
269
|
+
expect(user1.userPlans[0].plan.name).toEqual(PlanName.DEBUG_ALLOW_ALL);
|
|
270
|
+
expect(user1.features.myVault).toEqual([FeatureAction.ACCESS]);
|
|
271
|
+
expect(user1.features.shareVault).toEqual([FeatureAction.ACCESS]);
|
|
272
|
+
expect(user1.features.tpVault).toEqual([FeatureAction.ACCESS]);
|
|
273
|
+
|
|
274
|
+
// Wait for plan to end
|
|
275
|
+
await new Promise((res) => setTimeout(res, 1000 * endSeconds));
|
|
276
|
+
|
|
277
|
+
user1 = await authService.getUser(true);
|
|
278
|
+
expect(user1.userPlans.length).toBe(0);
|
|
279
|
+
|
|
280
|
+
// Add one again
|
|
281
|
+
await debugCreateUserPlan(PlanName.DEBUG_ALLOW_ALL);
|
|
282
|
+
|
|
283
|
+
// Make sure user2 is a TP
|
|
284
|
+
await setupTps(username1, password1, username2, password2);
|
|
285
|
+
|
|
286
|
+
await loginTestUser(username2, password2);
|
|
287
|
+
|
|
288
|
+
const tps = await tpService.getTrustedParties();
|
|
289
|
+
const user2Tp1 = tps.find((tp) => tp.username === username1);
|
|
290
|
+
expect(user2Tp1.features.sharedVault.hasAccess).toBeTrue();
|
|
291
|
+
},
|
|
292
|
+
TIMEOUT
|
|
293
|
+
);
|
|
294
|
+
});
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
CreateStripeCheckoutSessionMutation,
|
|
4
|
+
CreateStripeBillingPortalSessionMutation,
|
|
5
|
+
UserIssuablePlansQuery,
|
|
6
|
+
CreateUserIssuedPlanMutation,
|
|
7
|
+
DeleteUserIssuedPlanMutation,
|
|
8
|
+
UserIssuedPlansQuery,
|
|
9
|
+
AssociateUserIssuedPlanMutation,
|
|
10
|
+
UserPlansQuery,
|
|
11
|
+
StripeQuery,
|
|
12
|
+
UserIssuedPlanQuery,
|
|
13
|
+
} from './plan.gql';
|
|
14
|
+
import { LrApolloService } from '../api/lr-apollo.service';
|
|
15
|
+
import {
|
|
16
|
+
StripeCheckoutSession,
|
|
17
|
+
StripeBillingPortalSession,
|
|
18
|
+
UserIssuablePlan,
|
|
19
|
+
UserIssuedPlan,
|
|
20
|
+
UserPlan,
|
|
21
|
+
} from './plan.types';
|
|
22
|
+
import { LrBadArgumentException } from '../_common/exceptions';
|
|
23
|
+
|
|
24
|
+
export function mapUserPlans(userPlans: any[]): UserPlan[] {
|
|
25
|
+
return userPlans.map((t) => ({
|
|
26
|
+
...t,
|
|
27
|
+
periodEnd: t.periodEnd && new Date(t.periodEnd),
|
|
28
|
+
subscription: { id: t.stripe?.subscriptionId },
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Injectable({
|
|
33
|
+
providedIn: 'root',
|
|
34
|
+
})
|
|
35
|
+
export class PlanService {
|
|
36
|
+
constructor(private lrApollo: LrApolloService) {}
|
|
37
|
+
|
|
38
|
+
async createStripeCheckoutSession(input: {
|
|
39
|
+
priceId: string;
|
|
40
|
+
successUrl: string;
|
|
41
|
+
cancelUrl: string;
|
|
42
|
+
}): Promise<StripeCheckoutSession> {
|
|
43
|
+
const res = await this.lrApollo.mutate<{
|
|
44
|
+
createStripeCheckoutSession: any;
|
|
45
|
+
}>({
|
|
46
|
+
mutation: CreateStripeCheckoutSessionMutation,
|
|
47
|
+
variables: {
|
|
48
|
+
...input,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
id: res.createStripeCheckoutSession.sessionId,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async createStripeBillingPortalSession(
|
|
57
|
+
returnUrl: string
|
|
58
|
+
): Promise<StripeBillingPortalSession> {
|
|
59
|
+
const res = await this.lrApollo.mutate<{
|
|
60
|
+
createStripeBillingPortalSession: any;
|
|
61
|
+
}>({
|
|
62
|
+
mutation: CreateStripeBillingPortalSessionMutation,
|
|
63
|
+
variables: {
|
|
64
|
+
returnUrl,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
url: res.createStripeBillingPortalSession.sessionUrl,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async getUserIssuablePlans(): Promise<UserIssuablePlan[]> {
|
|
73
|
+
const { userIssuablePlans } = await this.lrApollo.query<{
|
|
74
|
+
userIssuablePlans: any;
|
|
75
|
+
}>({
|
|
76
|
+
query: UserIssuablePlansQuery,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return userIssuablePlans;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async createUserIssuedPlan({
|
|
83
|
+
planName,
|
|
84
|
+
tokenExpiryTime,
|
|
85
|
+
planPeriodEnd,
|
|
86
|
+
planPeriodEndAfterSeconds,
|
|
87
|
+
}: {
|
|
88
|
+
planName: string;
|
|
89
|
+
tokenExpiryTime: Date;
|
|
90
|
+
planPeriodEnd?: Date;
|
|
91
|
+
planPeriodEndAfterSeconds?: number;
|
|
92
|
+
}): Promise<UserIssuedPlan> {
|
|
93
|
+
if (planPeriodEnd == null && planPeriodEndAfterSeconds == null) {
|
|
94
|
+
throw new LrBadArgumentException(
|
|
95
|
+
'Must specify either "planPeriodEnd" or "planPeriodEndAfterSeconds"'
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const { createUserIssuedPlan } = await this.lrApollo.mutate<any>({
|
|
100
|
+
mutation: CreateUserIssuedPlanMutation,
|
|
101
|
+
variables: {
|
|
102
|
+
input: {
|
|
103
|
+
planName,
|
|
104
|
+
tokenExpiryTime: tokenExpiryTime.toISOString(),
|
|
105
|
+
planPeriodEnd: planPeriodEnd && planPeriodEnd.toISOString(),
|
|
106
|
+
planPeriodEndAfterSeconds,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const { userIssuedPlan } = createUserIssuedPlan;
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
...userIssuedPlan,
|
|
115
|
+
tokenExpiryTime: new Date(userIssuedPlan.tokenExpiryTime),
|
|
116
|
+
planPeriodEnd: new Date(userIssuedPlan.planPeriodEnd),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async deleteUserIssuedPlan(id: string): Promise<void> {
|
|
121
|
+
return await this.lrApollo.mutate<any>({
|
|
122
|
+
mutation: DeleteUserIssuedPlanMutation,
|
|
123
|
+
variables: {
|
|
124
|
+
input: {
|
|
125
|
+
id,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async getUserIssuedPlans(): Promise<any[]> {
|
|
132
|
+
const { userIssuedPlans } = await this.lrApollo.query<any>({
|
|
133
|
+
query: UserIssuedPlansQuery,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return userIssuedPlans.edges.map((edge) => edge.node);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async getUserIssuedPlan(id: string, token?: string): Promise<any> {
|
|
140
|
+
const { userIssuedPlan } = await this.lrApollo.query<any>({
|
|
141
|
+
query: UserIssuedPlanQuery,
|
|
142
|
+
variables: {
|
|
143
|
+
id,
|
|
144
|
+
token,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return userIssuedPlan;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async associateUserIssuedPlan({
|
|
152
|
+
id,
|
|
153
|
+
token,
|
|
154
|
+
}: {
|
|
155
|
+
id: string;
|
|
156
|
+
token: string;
|
|
157
|
+
}): Promise<UserPlan> {
|
|
158
|
+
const { associateUserIssuedPlan } = await this.lrApollo.query<any>({
|
|
159
|
+
query: AssociateUserIssuedPlanMutation,
|
|
160
|
+
variables: {
|
|
161
|
+
input: {
|
|
162
|
+
id,
|
|
163
|
+
token,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const { userPlan } = associateUserIssuedPlan;
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
...userPlan,
|
|
172
|
+
periodEnd: new Date(userPlan.periodEnd),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async getUserPlans(): Promise<UserPlan[]> {
|
|
177
|
+
const { userPlans } = await this.lrApollo.query<any>({
|
|
178
|
+
query: UserPlansQuery,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return mapUserPlans(userPlans);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async getPlanType(subscriptionId: string): Promise<string> {
|
|
185
|
+
const stripe: any = await this.getStripe();
|
|
186
|
+
return stripe.customer.subscriptions.data.filter(
|
|
187
|
+
(sub) => sub.id === subscriptionId
|
|
188
|
+
)[0].items.data[0].plan.interval;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async getStripe(): Promise<{ id: string; customer: object }> {
|
|
192
|
+
const { stripe } = await this.lrApollo.query<any>({
|
|
193
|
+
query: StripeQuery,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
return stripe;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class Plan {
|
|
2
|
+
name: string;
|
|
3
|
+
data: object;
|
|
4
|
+
state: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export class Subscription {
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class UserPlan {
|
|
12
|
+
id: string;
|
|
13
|
+
plan: Plan;
|
|
14
|
+
periodEnd: Date;
|
|
15
|
+
subscription: Subscription;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class StripeCheckoutSession {
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class StripeBillingPortalSession {
|
|
23
|
+
url: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface UserIssuablePlan {
|
|
27
|
+
plan: Plan;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface UserIssuedPlan {
|
|
31
|
+
id: string;
|
|
32
|
+
plan: Plan;
|
|
33
|
+
token: string;
|
|
34
|
+
tokenExpiryTime: Date;
|
|
35
|
+
planPeriodEnd: Date;
|
|
36
|
+
planPeriodEndAfterSeconds: number;
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { FileService } from '../api/file.service';
|
|
3
|
+
import { LrApolloService } from '../api/lr-apollo.service';
|
|
4
|
+
import { KeyGraphService } from '../cryptography/key-graph.service';
|
|
5
|
+
import { KeyMetaService } from '../cryptography/key-meta.service';
|
|
6
|
+
import { lrConfigureTestingModule } from '../_common/tests';
|
|
7
|
+
import { RecordAttachmentService } from './record-attachment.service';
|
|
8
|
+
|
|
9
|
+
const fileService = jasmine.createSpyObj<FileService>('FileService', [
|
|
10
|
+
'downloadEncryptedFile',
|
|
11
|
+
]);
|
|
12
|
+
const lrApollo = jasmine.createSpyObj<LrApolloService>('LrApolloService', [
|
|
13
|
+
'mutate',
|
|
14
|
+
]);
|
|
15
|
+
const keyGraphService = jasmine.createSpyObj<KeyGraphService>(
|
|
16
|
+
'KeyGraphService',
|
|
17
|
+
['decryptFile']
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
describe('RecordAttachmentService', () => {
|
|
21
|
+
let service: RecordAttachmentService;
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
lrConfigureTestingModule();
|
|
25
|
+
service = TestBed.inject(RecordAttachmentService);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should be created', () => {
|
|
29
|
+
expect(service).toBeTruthy();
|
|
30
|
+
});
|
|
31
|
+
});
|