@learncard/learn-cloud-service 2.5.33 → 2.5.35

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.
Files changed (89) hide show
  1. package/.env.example +13 -0
  2. package/CHANGELOG.md +38 -0
  3. package/dist/accesslayer/share-content/delete.d.ts +5 -0
  4. package/dist/accesslayer/share-content/delete.d.ts.map +1 -0
  5. package/dist/accesslayer/share-content/index.d.ts +8 -0
  6. package/dist/accesslayer/share-content/index.d.ts.map +1 -0
  7. package/dist/accesslayer/share-content/initialize.d.ts +5 -0
  8. package/dist/accesslayer/share-content/initialize.d.ts.map +1 -0
  9. package/dist/accesslayer/share-content/internal.d.ts +12 -0
  10. package/dist/accesslayer/share-content/internal.d.ts.map +1 -0
  11. package/dist/accesslayer/share-content/put.d.ts +5 -0
  12. package/dist/accesslayer/share-content/put.d.ts.map +1 -0
  13. package/dist/accesslayer/share-content/read.d.ts +7 -0
  14. package/dist/accesslayer/share-content/read.d.ts.map +1 -0
  15. package/dist/accesslayer/share-content/types.d.ts +85 -0
  16. package/dist/accesslayer/share-content/types.d.ts.map +1 -0
  17. package/dist/config/environment.d.ts +12 -0
  18. package/dist/config/environment.d.ts.map +1 -1
  19. package/dist/helpers/share-content-auth/adapters.d.ts +12 -0
  20. package/dist/helpers/share-content-auth/adapters.d.ts.map +1 -0
  21. package/dist/helpers/share-content-auth/canonical.d.ts +15 -0
  22. package/dist/helpers/share-content-auth/canonical.d.ts.map +1 -0
  23. package/dist/helpers/share-content-auth/claims.d.ts +19 -0
  24. package/dist/helpers/share-content-auth/claims.d.ts.map +1 -0
  25. package/dist/helpers/share-content-auth/config.d.ts +12 -0
  26. package/dist/helpers/share-content-auth/config.d.ts.map +1 -0
  27. package/dist/helpers/share-content-auth/index.d.ts +8 -0
  28. package/dist/helpers/share-content-auth/index.d.ts.map +1 -0
  29. package/dist/helpers/share-content-auth/token.d.ts +28 -0
  30. package/dist/helpers/share-content-auth/token.d.ts.map +1 -0
  31. package/dist/helpers/share-content-auth/types.d.ts +70 -0
  32. package/dist/helpers/share-content-auth/types.d.ts.map +1 -0
  33. package/dist/helpers/share-content-auth/verifier.d.ts +9 -0
  34. package/dist/helpers/share-content-auth/verifier.d.ts.map +1 -0
  35. package/dist/index.js +2 -2
  36. package/dist/models/ShareContent.d.ts +160 -0
  37. package/dist/models/ShareContent.d.ts.map +1 -0
  38. package/dist/models/index.d.ts +1 -0
  39. package/dist/models/index.d.ts.map +1 -1
  40. package/dist/share-content/config.d.ts +28 -0
  41. package/dist/share-content/config.d.ts.map +1 -0
  42. package/dist/share-content/index.d.ts +6 -0
  43. package/dist/share-content/index.d.ts.map +1 -0
  44. package/dist/share-content/plugin.d.ts +5 -0
  45. package/dist/share-content/plugin.d.ts.map +1 -0
  46. package/dist/share-content/production.d.ts +15 -0
  47. package/dist/share-content/production.d.ts.map +1 -0
  48. package/dist/share-content/runtime.d.ts +23 -0
  49. package/dist/share-content/runtime.d.ts.map +1 -0
  50. package/dist/share-content/types.d.ts +23 -0
  51. package/dist/share-content/types.d.ts.map +1 -0
  52. package/lambda.ts +61 -0
  53. package/package.json +14 -14
  54. package/serverless.yml +25 -0
  55. package/src/accesslayer/share-content/delete.ts +124 -0
  56. package/src/accesslayer/share-content/index.ts +70 -0
  57. package/src/accesslayer/share-content/initialize.ts +24 -0
  58. package/src/accesslayer/share-content/internal.ts +89 -0
  59. package/src/accesslayer/share-content/put.ts +93 -0
  60. package/src/accesslayer/share-content/read.ts +124 -0
  61. package/src/accesslayer/share-content/types.ts +155 -0
  62. package/src/config/environment.ts +33 -0
  63. package/src/docker-entry.ts +19 -0
  64. package/src/helpers/share-content-auth/adapters.ts +48 -0
  65. package/src/helpers/share-content-auth/canonical.ts +91 -0
  66. package/src/helpers/share-content-auth/claims.ts +164 -0
  67. package/src/helpers/share-content-auth/config.ts +160 -0
  68. package/src/helpers/share-content-auth/index.ts +59 -0
  69. package/src/helpers/share-content-auth/token.ts +148 -0
  70. package/src/helpers/share-content-auth/types.ts +195 -0
  71. package/src/helpers/share-content-auth/verifier.ts +220 -0
  72. package/src/models/ShareContent.ts +198 -0
  73. package/src/models/index.ts +1 -0
  74. package/src/share-content/config.ts +199 -0
  75. package/src/share-content/index.ts +5 -0
  76. package/src/share-content/plugin.ts +317 -0
  77. package/src/share-content/production.ts +107 -0
  78. package/src/share-content/runtime.ts +90 -0
  79. package/src/share-content/types.ts +59 -0
  80. package/test/share-content-auth.spec.ts +1161 -0
  81. package/test/share-content-config.spec.ts +252 -0
  82. package/test/share-content-didkit.spec.ts +411 -0
  83. package/test/share-content-endpoint.spec.ts +825 -0
  84. package/test/share-content-redis-setup.ts +18 -0
  85. package/test/share-content.spec.ts +681 -0
  86. package/vitest.config.ts +1 -0
  87. package/vitest.share-content-config-unit.config.ts +8 -0
  88. package/vitest.share-content-endpoint.config.ts +21 -0
  89. package/vitest.share-content.config.ts +19 -0
package/.env.example CHANGED
@@ -21,3 +21,16 @@ SENTRY_ENV=development
21
21
  IS_OFFLINE=false
22
22
  SKIP_DIDKIT_NAPI=false
23
23
  CI=false
24
+
25
+ # LC-2187 service-only share-content routes start with valid service configuration.
26
+ # All four values are required and REDIS_HOST/REDIS_PORT must point at the real
27
+ # replay store. Real values are provisioned per environment, never committed.
28
+ # LearnCloud's own service DID that service tokens must address.
29
+ SHARE_CONTENT_AUDIENCE=
30
+ # Comma-separated allowlisted Brain service DIDs.
31
+ SHARE_CONTENT_SERVICE_DIDS=
32
+ # Comma-separated exact JWS `kid` verification methods (DID URL with fragment).
33
+ SHARE_CONTENT_VERIFICATION_METHODS=
34
+ # JSON object mapping each service DID to the namespaces it may use, e.g.
35
+ # {"did:web:brain.example":["learncard"]}
36
+ SHARE_CONTENT_NAMESPACE_BINDINGS=
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @learncard/network-brain-service
2
2
 
3
+ ## 2.5.35
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`4b83aa9ee802f0d7a54adc5f053a7376fa103cdd`](https://github.com/learningeconomy/LearnCard/commit/4b83aa9ee802f0d7a54adc5f053a7376fa103cdd), [`b184f5552abf37a11468d435e5cea07fc35e1993`](https://github.com/learningeconomy/LearnCard/commit/b184f5552abf37a11468d435e5cea07fc35e1993), [`0e262737aafb8248e88e05039c83a3f30be6750f`](https://github.com/learningeconomy/LearnCard/commit/0e262737aafb8248e88e05039c83a3f30be6750f), [`d436c39e00994e6d8c77e7b94985a51fe1f42adb`](https://github.com/learningeconomy/LearnCard/commit/d436c39e00994e6d8c77e7b94985a51fe1f42adb)]:
8
+ - @learncard/types@5.22.0
9
+ - @learncard/helpers@1.6.1
10
+ - @learncard/core@9.4.37
11
+ - @learncard/did-web-plugin@1.1.37
12
+ - @learncard/didkey-plugin@1.1.37
13
+ - @learncard/didkit-plugin@1.10.2
14
+ - @learncard/didkit-plugin-node@0.3.2
15
+ - @learncard/encryption-plugin@1.1.37
16
+ - @learncard/learn-card-plugin@1.2.37
17
+ - @learncard/vc-plugin@1.6.3
18
+ - @learncard/vc-templates-plugin@1.1.37
19
+ - @learncard/crypto-plugin@1.1.37
20
+ - @learncard/expiration-plugin@1.2.37
21
+
22
+ ## 2.5.34
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [[`2991bd32b03e26736239dd8e586e2f720d9bcd45`](https://github.com/learningeconomy/LearnCard/commit/2991bd32b03e26736239dd8e586e2f720d9bcd45), [`0c1bf9a8a33e6392d5fd279479d9ab4fb0449b5e`](https://github.com/learningeconomy/LearnCard/commit/0c1bf9a8a33e6392d5fd279479d9ab4fb0449b5e), [`3174c09b97fde6f7b5251390245038cf6b7ea9ba`](https://github.com/learningeconomy/LearnCard/commit/3174c09b97fde6f7b5251390245038cf6b7ea9ba), [`928e587378b3674766cf58a8bbe1cbd4d66d3a9f`](https://github.com/learningeconomy/LearnCard/commit/928e587378b3674766cf58a8bbe1cbd4d66d3a9f), [`928e587378b3674766cf58a8bbe1cbd4d66d3a9f`](https://github.com/learningeconomy/LearnCard/commit/928e587378b3674766cf58a8bbe1cbd4d66d3a9f)]:
27
+ - @learncard/types@5.21.0
28
+ - @learncard/helpers@1.6.0
29
+ - @learncard/vc-plugin@1.6.2
30
+ - @learncard/core@9.4.36
31
+ - @learncard/did-web-plugin@1.1.36
32
+ - @learncard/didkey-plugin@1.1.36
33
+ - @learncard/didkit-plugin@1.10.1
34
+ - @learncard/didkit-plugin-node@0.3.1
35
+ - @learncard/encryption-plugin@1.1.36
36
+ - @learncard/learn-card-plugin@1.2.36
37
+ - @learncard/vc-templates-plugin@1.1.36
38
+ - @learncard/crypto-plugin@1.1.36
39
+ - @learncard/expiration-plugin@1.2.36
40
+
3
41
  ## 2.5.33
4
42
 
5
43
  ### Patch Changes
@@ -0,0 +1,5 @@
1
+ import type { Collection } from 'mongodb';
2
+ import type { MongoShareContentDocument } from '../.././models/index';
3
+ import type { ShareContentRepositoryResult, ShareContentTombstoneSummary } from './types';
4
+ export declare const deleteShareContent: (collection: Collection<MongoShareContentDocument>, rawBinding: unknown) => Promise<ShareContentRepositoryResult<ShareContentTombstoneSummary>>;
5
+ //# sourceMappingURL=delete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/accesslayer/share-content/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAUzD,OAAO,KAAK,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAgB1F,eAAO,MAAM,kBAAkB,GAC3B,YAAY,UAAU,CAAC,yBAAyB,CAAC,EACjD,YAAY,OAAO,KACpB,OAAO,CAAC,4BAA4B,CAAC,4BAA4B,CAAC,CA4FpE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Collection, Db } from 'mongodb';
2
+ import { type MongoShareContentDocument } from '../.././models/index';
3
+ import type { ShareContentRepository } from './types';
4
+ export * from './types';
5
+ export { ensureShareContentIndexes, SHARE_CONTENT_IDENTITY_INDEX } from './initialize';
6
+ export declare const getShareContentCollection: (db: Db) => Collection<MongoShareContentDocument>;
7
+ export declare const createShareContentRepository: (collection: Collection<MongoShareContentDocument>) => ShareContentRepository;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/accesslayer/share-content/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAEH,KAAK,yBAAyB,EAGjC,MAAM,SAAS,CAAC;AAOjB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAOvF,eAAO,MAAM,yBAAyB,GAAI,IAAI,EAAE,KAAG,UAAU,CAAC,yBAAyB,CACjB,CAAC;AAiBvE,eAAO,MAAM,4BAA4B,GACrC,YAAY,UAAU,CAAC,yBAAyB,CAAC,KAClD,sBAyBF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Collection } from 'mongodb';
2
+ import type { MongoShareContentDocument } from '../.././models/index';
3
+ export declare const SHARE_CONTENT_IDENTITY_INDEX = "share_content_identity_unique";
4
+ export declare const ensureShareContentIndexes: (collection: Collection<MongoShareContentDocument>) => Promise<void>;
5
+ //# sourceMappingURL=initialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/accesslayer/share-content/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAGzD,eAAO,MAAM,4BAA4B,kCAAkC,CAAC;AAW5E,eAAO,MAAM,yBAAyB,GAClC,YAAY,UAAU,CAAC,yBAAyB,CAAC,KAClD,OAAO,CAAC,IAAI,CAKd,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Filter } from 'mongodb';
2
+ import { type MongoShareContentActive, type MongoShareContentDocument, type MongoShareContentTombstone, type ShareContentObjectBinding } from '../.././models/index';
3
+ import type { ShareContentActiveSummary, ShareContentTombstoneSummary } from './types';
4
+ export declare const MAX_SHARE_CONTENT_ATTEMPTS = 5;
5
+ export declare const parseShareContentBinding: (raw: unknown) => ShareContentObjectBinding | null;
6
+ export declare const shareContentBindingFilter: (binding: ShareContentObjectBinding) => Filter<MongoShareContentDocument>;
7
+ export declare const shareContentIdentityFilter: (binding: Pick<ShareContentObjectBinding, "namespace" | "objectId">) => Filter<MongoShareContentDocument>;
8
+ export declare const bindingMatchesDocument: (doc: MongoShareContentDocument, binding: ShareContentObjectBinding) => boolean;
9
+ export declare const isDuplicateKeyError: (error: unknown) => boolean;
10
+ export declare const toActiveSummary: (doc: MongoShareContentActive) => ShareContentActiveSummary;
11
+ export declare const toTombstoneSummary: (doc: MongoShareContentTombstone) => ShareContentTombstoneSummary;
12
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/accesslayer/share-content/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,EAEH,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EACjC,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAQvF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,eAAO,MAAM,wBAAwB,GAAI,KAAK,OAAO,KAAG,yBAAyB,GAAG,IAInF,CAAC;AAGF,eAAO,MAAM,yBAAyB,GAClC,SAAS,yBAAyB,KACnC,MAAM,CAAC,yBAAyB,CAOjC,CAAC;AAGH,eAAO,MAAM,0BAA0B,GACnC,SAAS,IAAI,CAAC,yBAAyB,EAAE,WAAW,GAAG,UAAU,CAAC,KACnE,MAAM,CAAC,yBAAyB,CAGjC,CAAC;AAEH,eAAO,MAAM,sBAAsB,GAC/B,KAAK,yBAAyB,EAC9B,SAAS,yBAAyB,KACnC,OAMwC,CAAC;AAG5C,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,OAC0C,CAAC;AAEhG,eAAO,MAAM,eAAe,GAAI,KAAK,uBAAuB,KAAG,yBAa7D,CAAC;AAEH,eAAO,MAAM,kBAAkB,GAC3B,KAAK,0BAA0B,KAChC,4BAUD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Collection } from 'mongodb';
2
+ import { type MongoShareContentDocument } from '../.././models/index';
3
+ import type { ShareContentPutResult } from './types';
4
+ export declare const putShareContent: (collection: Collection<MongoShareContentDocument>, rawInput: unknown) => Promise<ShareContentPutResult>;
5
+ //# sourceMappingURL=put.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"put.d.ts","sourceRoot":"","sources":["../../../src/accesslayer/share-content/put.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,EAMH,KAAK,yBAAyB,EAEjC,MAAM,SAAS,CAAC;AASjB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAqCrD,eAAO,MAAM,eAAe,GACxB,YAAY,UAAU,CAAC,yBAAyB,CAAC,EACjD,UAAU,OAAO,KAClB,OAAO,CAAC,qBAAqB,CAiC/B,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Collection } from 'mongodb';
2
+ import type { MongoShareContentDocument } from '../.././models/index';
3
+ import type { ShareContentContentProjection, ShareContentRecoveryProjection, ShareContentRepositoryResult, ShareContentStatProjection } from './types';
4
+ export declare const getShareContentContent: (collection: Collection<MongoShareContentDocument>, rawBinding: unknown) => Promise<ShareContentRepositoryResult<ShareContentContentProjection>>;
5
+ export declare const getShareContentRecovery: (collection: Collection<MongoShareContentDocument>, rawBinding: unknown) => Promise<ShareContentRepositoryResult<ShareContentRecoveryProjection>>;
6
+ export declare const statShareContent: (collection: Collection<MongoShareContentDocument>, rawBinding: unknown) => Promise<ShareContentRepositoryResult<ShareContentStatProjection>>;
7
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/accesslayer/share-content/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAQzD,OAAO,KAAK,EACR,6BAA6B,EAC7B,8BAA8B,EAC9B,4BAA4B,EAC5B,0BAA0B,EAC7B,MAAM,SAAS,CAAC;AAQjB,eAAO,MAAM,sBAAsB,GAC/B,YAAY,UAAU,CAAC,yBAAyB,CAAC,EACjD,YAAY,OAAO,KACpB,OAAO,CAAC,4BAA4B,CAAC,6BAA6B,CAAC,CA6BrE,CAAC;AAQF,eAAO,MAAM,uBAAuB,GAChC,YAAY,UAAU,CAAC,yBAAyB,CAAC,EACjD,YAAY,OAAO,KACpB,OAAO,CAAC,4BAA4B,CAAC,8BAA8B,CAAC,CA6BtE,CAAC;AAOF,eAAO,MAAM,gBAAgB,GACzB,YAAY,UAAU,CAAC,yBAAyB,CAAC,EACjD,YAAY,OAAO,KACpB,OAAO,CAAC,4BAA4B,CAAC,0BAA0B,CAAC,CAkBlE,CAAC"}
@@ -0,0 +1,85 @@
1
+ import type { Collection } from 'mongodb';
2
+ import type { MongoShareContentDocument, ShareContentHash, ShareContentObjectBinding, ShareContentPutInput, ShareEnvelope, ShareOwnerRecovery } from '../.././models/index';
3
+ export type ShareContentRepositoryError = 'INVALID_INPUT' | 'NOT_FOUND' | 'TOMBSTONED' | 'BINDING_MISMATCH' | 'CONFLICT' | 'STORE_ERROR';
4
+ export type ShareContentRepositoryFailure = {
5
+ ok: false;
6
+ error: ShareContentRepositoryError;
7
+ };
8
+ export type ShareContentRepositoryResult<T> = {
9
+ ok: true;
10
+ value: T;
11
+ } | ShareContentRepositoryFailure;
12
+ export type ShareContentWriteStatus = 'created' | 'idempotent';
13
+ export type ShareContentActiveSummary = {
14
+ kind: 'active';
15
+ namespace: string;
16
+ ownerProfileId: string;
17
+ shareId: string;
18
+ contentVersion: number;
19
+ objectId: string;
20
+ operationId: string;
21
+ contentHash: ShareContentHash;
22
+ payloadHash: ShareContentHash;
23
+ ciphertextBytes: number;
24
+ recoveryBytes: number;
25
+ createdAt: Date;
26
+ };
27
+ export type ShareContentTombstoneSummary = {
28
+ kind: 'tombstone';
29
+ namespace: string;
30
+ ownerProfileId: string;
31
+ shareId: string;
32
+ contentVersion: number;
33
+ objectId: string;
34
+ operationId: string;
35
+ contentHash?: ShareContentHash;
36
+ deletedAt: Date;
37
+ };
38
+ export type ShareContentContentProjection = {
39
+ kind: 'active';
40
+ namespace: string;
41
+ ownerProfileId: string;
42
+ shareId: string;
43
+ contentVersion: number;
44
+ objectId: string;
45
+ operationId: string;
46
+ contentHash: ShareContentHash;
47
+ payloadHash: ShareContentHash;
48
+ envelope: ShareEnvelope;
49
+ ciphertextBytes: number;
50
+ createdAt: Date;
51
+ };
52
+ export type ShareContentRecoveryProjection = {
53
+ kind: 'active';
54
+ namespace: string;
55
+ ownerProfileId: string;
56
+ shareId: string;
57
+ contentVersion: number;
58
+ objectId: string;
59
+ operationId: string;
60
+ contentHash: ShareContentHash;
61
+ payloadHash: ShareContentHash;
62
+ ownerEncryptedRecovery: ShareOwnerRecovery;
63
+ recoveryBytes: number;
64
+ createdAt: Date;
65
+ };
66
+ export type ShareContentStatProjection = ShareContentActiveSummary | ShareContentTombstoneSummary;
67
+ export type ShareContentPutResultValue = {
68
+ status: ShareContentWriteStatus;
69
+ record: ShareContentActiveSummary;
70
+ };
71
+ export type ShareContentPutResult = ShareContentRepositoryResult<ShareContentPutResultValue>;
72
+ export type ShareContentRepository = {
73
+ readonly collection: Collection<MongoShareContentDocument>;
74
+ initialize: () => Promise<void>;
75
+ put: (input: ShareContentPutInput) => Promise<ShareContentPutResult>;
76
+ getContent: (binding: ShareContentObjectBinding) => Promise<ShareContentRepositoryResult<ShareContentContentProjection>>;
77
+ getRecovery: (binding: ShareContentObjectBinding) => Promise<ShareContentRepositoryResult<ShareContentRecoveryProjection>>;
78
+ stat: (binding: ShareContentObjectBinding) => Promise<ShareContentRepositoryResult<ShareContentStatProjection>>;
79
+ delete: (binding: ShareContentObjectBinding) => Promise<ShareContentRepositoryResult<ShareContentTombstoneSummary>>;
80
+ };
81
+ export declare class ShareContentRepositoryNotInitializedError extends Error {
82
+ readonly code = "SHARE_CONTENT_REPOSITORY_NOT_INITIALIZED";
83
+ constructor();
84
+ }
85
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/accesslayer/share-content/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,KAAK,EACR,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EACrB,MAAM,SAAS,CAAC;AAOjB,MAAM,MAAM,2BAA2B,GACnC,eAAe,GAAG,WAAW,GAAG,YAAY,GAAG,kBAAkB,GAAG,UAAU,GAAG,aAAa,CAAC;AAEnG,MAAM,MAAM,6BAA6B,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,2BAA2B,CAAA;CAAE,CAAC;AAE9F,MAAM,MAAM,4BAA4B,CAAC,CAAC,IACtC;IAAE,EAAE,EAAE,IAA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B,CAAC,CAAC,CAAC;IAKvE,MAAM,EAAE,CACJ,OAAO,EAAE,yBAAyB,KACjC,OAAO,CAAC,4BAA4B,CAAC,4BAA4B,CAAC,CAAC,CAAC;CAC5E,CAAC;AAGF,qBAAa,yCAA0C,SAAQ,KAAK;IAChE,QAAQ,CAAC,IAAI,8CAA8C;;CAM9D"}
@@ -37,6 +37,10 @@ export declare const learnCloudServiceEnvironmentShape: {
37
37
  true: "true";
38
38
  false: "false";
39
39
  }>, z.ZodTransform<boolean, "0" | "1" | "true" | "false">>>>>;
40
+ SHARE_CONTENT_AUDIENCE: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
41
+ SHARE_CONTENT_SERVICE_DIDS: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
42
+ SHARE_CONTENT_VERIFICATION_METHODS: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
43
+ SHARE_CONTENT_NAMESPACE_BINDINGS: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
40
44
  };
41
45
  export declare const learnCloudServiceEnvironmentSchema: z.ZodObject<{
42
46
  NODE_ENV: z.ZodDefault<z.ZodEnum<{
@@ -75,6 +79,10 @@ export declare const learnCloudServiceEnvironmentSchema: z.ZodObject<{
75
79
  true: "true";
76
80
  false: "false";
77
81
  }>, z.ZodTransform<boolean, "0" | "1" | "true" | "false">>>>>;
82
+ SHARE_CONTENT_AUDIENCE: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
83
+ SHARE_CONTENT_SERVICE_DIDS: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
84
+ SHARE_CONTENT_VERIFICATION_METHODS: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
85
+ SHARE_CONTENT_NAMESPACE_BINDINGS: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
78
86
  }, z.core.$strip>;
79
87
  export type LearnCloudServiceEnvironment = z.output<typeof learnCloudServiceEnvironmentSchema>;
80
88
  export declare const parseLearnCloudServiceEnvironment: (raw: Record<string, unknown>, source?: string) => LearnCloudServiceEnvironment;
@@ -96,5 +104,9 @@ export declare const environment: {
96
104
  REDIS_PORT?: number | undefined;
97
105
  SENTRY_DSN?: string | undefined;
98
106
  SENTRY_ENV?: string | undefined;
107
+ SHARE_CONTENT_AUDIENCE?: string | undefined;
108
+ SHARE_CONTENT_SERVICE_DIDS?: string | undefined;
109
+ SHARE_CONTENT_VERIFICATION_METHODS?: string | undefined;
110
+ SHARE_CONTENT_NAMESPACE_BINDINGS?: string | undefined;
99
111
  };
100
112
  //# sourceMappingURL=environment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/config/environment.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBrB,CAAC;AAE1B,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBzC,CAAC;AAEP,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE/F,eAAO,MAAM,iCAAiC,GAC1C,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,eAA8B,KAC/B,4BAmBF,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;CAAiD,CAAC"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/config/environment.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBrB,CAAC;AAE1B,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmDzC,CAAC;AAEP,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE/F,eAAO,MAAM,iCAAiC,GAC1C,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,eAA8B,KAC/B,4BAmBF,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;CAAiD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { PresentationVerificationResult, PresentationVerifier, ReplayStore } from './types';
2
+ export type LearnCardLike = {
3
+ invoke: {
4
+ verifyPresentation: (token: string, options: {
5
+ proofFormat: 'jwt';
6
+ }) => Promise<PresentationVerificationResult>;
7
+ };
8
+ };
9
+ export declare const createDidkitPresentationVerifier: (getLearnCard: () => Promise<LearnCardLike>) => PresentationVerifier;
10
+ export type SetIfAbsent = (key: string, ttlSeconds: number) => Promise<boolean>;
11
+ export declare const createSetIfAbsentReplayStore: (setIfAbsent: SetIfAbsent) => ReplayStore;
12
+ //# sourceMappingURL=adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../../src/helpers/share-content-auth/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAWjG,MAAM,MAAM,aAAa,GAAG;IACxB,MAAM,EAAE;QACJ,kBAAkB,EAAE,CAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;YAAE,WAAW,EAAE,KAAK,CAAA;SAAE,KAC9B,OAAO,CAAC,8BAA8B,CAAC,CAAC;KAChD,CAAC;CACL,CAAC;AASF,eAAO,MAAM,gCAAgC,GACzC,cAAc,MAAM,OAAO,CAAC,aAAa,CAAC,KAC3C,oBAMF,CAAC;AAOF,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAGhF,eAAO,MAAM,4BAA4B,GAAI,aAAa,WAAW,KAAG,WAEtE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type ShareContentOperation } from './types';
2
+ export { canonicalizeShareContentRequestBody, DEFAULT_MAX_CANONICAL_BYTES as DEFAULT_MAX_CANONICAL_REQUEST_BYTES, DEFAULT_MAX_CANONICAL_DEPTH, ShareContentCanonicalizationError, } from '@learncard/helpers';
3
+ export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
4
+ export declare const isCanonicalBase64Url: (value: unknown, expectedBytes?: number) => value is string;
5
+ export declare const isSafeContentVersion: (value: unknown) => value is number;
6
+ export declare const isSafeEpochSecond: (value: unknown) => value is number;
7
+ export declare const isOpaqueIdentifier: (value: unknown, maxLength?: number) => value is string;
8
+ export declare const isBoundedNonce: (value: unknown, minLength: number, maxLength: number) => value is string;
9
+ export declare const isSha256Hex: (value: unknown) => value is string;
10
+ export declare const isShareContentOperation: (value: unknown) => value is ShareContentOperation;
11
+ export declare const computeShareContentRequestHash: (body: unknown, options?: {
12
+ maxBytes?: number;
13
+ maxDepth?: number;
14
+ }) => string;
15
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../../src/helpers/share-content-auth/canonical.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4B,KAAK,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAW/E,OAAO,EACH,mCAAmC,EACnC,2BAA2B,IAAI,mCAAmC,EAClE,2BAA2B,EAC3B,iCAAiC,GACpC,MAAM,oBAAoB,CAAC;AAO5B,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAM7E,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,EAAE,gBAAgB,MAAM,KAAG,KAAK,IAAI,MAUtF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACmC,CAAC;AAEnG,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACc,CAAC;AAM3E,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,EAAE,kBAAe,KAAG,KAAK,IAAI,MAI1C,CAAC;AAErC,eAAO,MAAM,cAAc,GACvB,OAAO,OAAO,EACd,WAAW,MAAM,EACjB,WAAW,MAAM,KAClB,KAAK,IAAI,MAIU,CAAC;AAEvB,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACI,CAAC;AAE3D,eAAO,MAAM,uBAAuB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,qBAC8B,CAAC;AAOjG,eAAO,MAAM,8BAA8B,GACvC,MAAM,OAAO,EACb,UAAS;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,KACvD,MAGmB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type ShareContentAuthorizationClaims, type ShareContentTrustConfig } from './types';
2
+ export declare const SHARE_ID_BYTES = 16;
3
+ export type SignedClaimsResult = {
4
+ ok: true;
5
+ raw: unknown;
6
+ } | {
7
+ ok: false;
8
+ reason: 'MALFORMED_CLAIMS';
9
+ };
10
+ export declare const extractSignedClaims: (payload: Record<string, unknown>) => SignedClaimsResult;
11
+ export type ParseClaimsResult = {
12
+ ok: true;
13
+ claims: ShareContentAuthorizationClaims;
14
+ } | {
15
+ ok: false;
16
+ reason: 'MALFORMED_CLAIMS' | 'UNKNOWN_CLAIM_FIELD' | 'INVALID_CLAIMS' | 'INVALID_SHARE_ID' | 'INVALID_IDENTIFIER' | 'INVALID_JTI' | 'OPERATION_NOT_ALLOWED' | 'PURPOSE_MISMATCH';
17
+ };
18
+ export declare const parseShareContentAuthorizationClaims: (raw: unknown, config: ShareContentTrustConfig) => ParseClaimsResult;
19
+ //# sourceMappingURL=claims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claims.d.ts","sourceRoot":"","sources":["../../../src/helpers/share-content-auth/claims.ts"],"names":[],"mappings":"AAUA,OAAO,EAGH,KAAK,+BAA+B,EACpC,KAAK,uBAAuB,EAC/B,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,cAAc,KAAK,CAAC;AAIjC,MAAM,MAAM,kBAAkB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAO3E,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,kBAyBtE,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,+BAA+B,CAAA;CAAE,GACrD;IACI,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EACA,kBAAkB,GAClB,qBAAqB,GACrB,gBAAgB,GAChB,kBAAkB,GAClB,oBAAoB,GACpB,aAAa,GACb,uBAAuB,GACvB,kBAAkB,CAAC;CAC5B,CAAC;AAOR,eAAO,MAAM,oCAAoC,GAC7C,KAAK,OAAO,EACZ,QAAQ,uBAAuB,KAChC,iBAmFF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ShareContentTrustConfig } from './types';
2
+ export declare const HARD_MAX_TOKEN_TTL_SECONDS = 60;
3
+ export declare const HARD_MAX_CLOCK_SKEW_SECONDS = 60;
4
+ export declare const HARD_MIN_TOKEN_BYTES = 256;
5
+ export declare const HARD_MAX_TOKEN_BYTES = 65536;
6
+ export declare const DEFAULT_MAX_TOKEN_BYTES = 8192;
7
+ export declare const DEFAULT_MIN_JTI_LENGTH = 16;
8
+ export declare const DEFAULT_MAX_JTI_LENGTH = 128;
9
+ export declare const DISABLED_SHARE_CONTENT_TRUST_CONFIG: ShareContentTrustConfig;
10
+ export declare const resolveShareContentTrustConfig: (raw: unknown) => ShareContentTrustConfig;
11
+ export declare const isShareContentTrustConfigActive: (config: ShareContentTrustConfig) => boolean;
12
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/helpers/share-content-auth/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAWvD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAC3C,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,mCAAmC,EAAE,uBAWhD,CAAC;AA2CH,eAAO,MAAM,8BAA8B,GAAI,KAAK,OAAO,KAAG,uBA+E7D,CAAC;AAGF,eAAO,MAAM,+BAA+B,GAAI,QAAQ,uBAAuB,KAAG,OAIlC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from './types';
2
+ export { SHARE_ID_BYTES, extractSignedClaims, parseShareContentAuthorizationClaims, } from './claims';
3
+ export { DEFAULT_MAX_CANONICAL_DEPTH, DEFAULT_MAX_CANONICAL_REQUEST_BYTES, ShareContentCanonicalizationError, canonicalizeShareContentRequestBody, computeShareContentRequestHash, isBoundedNonce, isCanonicalBase64Url, isOpaqueIdentifier, isPlainObject, isSafeContentVersion, isSafeEpochSecond, isSha256Hex, isShareContentOperation, } from './canonical';
4
+ export { DEFAULT_MAX_JTI_LENGTH, DEFAULT_MAX_TOKEN_BYTES, DEFAULT_MIN_JTI_LENGTH, DISABLED_SHARE_CONTENT_TRUST_CONFIG, HARD_MAX_CLOCK_SKEW_SECONDS, HARD_MAX_TOKEN_BYTES, HARD_MAX_TOKEN_TTL_SECONDS, HARD_MIN_TOKEN_BYTES, isShareContentTrustConfigActive, resolveShareContentTrustConfig, } from './config';
5
+ export { parseCompactJwt, validateShareContentJwtHeader } from './token';
6
+ export { createShareContentAuthorizationVerifier, type CreateShareContentAuthorizationVerifierDependencies, } from './verifier';
7
+ export { createDidkitPresentationVerifier, createSetIfAbsentReplayStore, type LearnCardLike, type SetIfAbsent, } from './adapters';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/share-content-auth/index.ts"],"names":[],"mappings":"AAeA,cAAc,SAAS,CAAC;AACxB,OAAO,EACH,cAAc,EACd,mBAAmB,EACnB,oCAAoC,GACvC,MAAM,UAAU,CAAC;AAClB,OAAO,EACH,2BAA2B,EAC3B,mCAAmC,EACnC,iCAAiC,EACjC,mCAAmC,EACnC,8BAA8B,EAC9B,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,uBAAuB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,mCAAmC,EACnC,2BAA2B,EAC3B,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,+BAA+B,EAC/B,8BAA8B,GACjC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EACH,uCAAuC,EACvC,KAAK,mDAAmD,GAC3D,MAAM,YAAY,CAAC;AACpB,OAAO,EACH,gCAAgC,EAChC,4BAA4B,EAC5B,KAAK,aAAa,EAClB,KAAK,WAAW,GACnB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { ShareContentTrustConfig } from './types';
2
+ export type ParsedCompactJwt = {
3
+ header: Record<string, unknown>;
4
+ payload: Record<string, unknown>;
5
+ signingInput: string;
6
+ signature: string;
7
+ };
8
+ export type ParseCompactJwtResult = {
9
+ ok: true;
10
+ parsed: ParsedCompactJwt;
11
+ } | {
12
+ ok: false;
13
+ reason: 'TOKEN_TOO_LARGE' | 'MALFORMED_TOKEN';
14
+ };
15
+ export declare const parseCompactJwt: (token: unknown, maxBytes: number) => ParseCompactJwtResult;
16
+ export type ValidatedJwtHeader = {
17
+ signerDid: string;
18
+ verificationMethod: string;
19
+ };
20
+ export type ValidateJwtHeaderResult = {
21
+ ok: true;
22
+ value: ValidatedJwtHeader;
23
+ } | {
24
+ ok: false;
25
+ reason: 'UNSUPPORTED_HEADER' | 'UNSUPPORTED_ALGORITHM' | 'MISSING_KID' | 'UNKNOWN_SIGNER' | 'UNKNOWN_VERIFICATION_METHOD';
26
+ };
27
+ export declare const validateShareContentJwtHeader: (header: Record<string, unknown>, config: ShareContentTrustConfig) => ValidateJwtHeaderResult;
28
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/helpers/share-content-auth/token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAcvD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC3B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GACtC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAAA;CAAE,CAAC;AAEnE,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,EAAE,UAAU,MAAM,KAAG,qBA8ClE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;IAElB,kBAAkB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC7B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GACvC;IACI,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EACA,oBAAoB,GACpB,uBAAuB,GACvB,aAAa,GACb,gBAAgB,GAChB,6BAA6B,CAAC;CACvC,CAAC;AAOR,eAAO,MAAM,6BAA6B,GACtC,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,QAAQ,uBAAuB,KAChC,uBA+CF,CAAC"}
@@ -0,0 +1,70 @@
1
+ export declare const SHARE_CONTENT_AUTH_PURPOSE: "lc-share-content/v1";
2
+ export declare const SHARE_CONTENT_OPERATIONS: readonly ["put", "get", "stat", "delete", "readRecovery"];
3
+ export type ShareContentOperation = (typeof SHARE_CONTENT_OPERATIONS)[number];
4
+ export declare const SHARE_CONTENT_CLAIM_FIELDS: readonly ["iss", "aud", "purpose", "namespace", "op", "shareId", "contentVersion", "ownerProfileId", "objectId", "operationId", "requestHash", "iat", "exp", "jti"];
5
+ export type ShareContentClaimField = (typeof SHARE_CONTENT_CLAIM_FIELDS)[number];
6
+ export type ShareContentAuthorizationClaims = {
7
+ iss: string;
8
+ aud: string;
9
+ purpose: typeof SHARE_CONTENT_AUTH_PURPOSE;
10
+ namespace: string;
11
+ op: ShareContentOperation;
12
+ shareId: string;
13
+ contentVersion: number;
14
+ ownerProfileId: string;
15
+ objectId: string;
16
+ operationId: string;
17
+ requestHash: string;
18
+ iat: number;
19
+ exp: number;
20
+ jti: string;
21
+ };
22
+ export type ShareContentAuthorizationRequest = {
23
+ namespace: string;
24
+ op: ShareContentOperation;
25
+ shareId: string;
26
+ contentVersion: number;
27
+ ownerProfileId: string;
28
+ objectId: string;
29
+ operationId: string;
30
+ requestHash: string;
31
+ };
32
+ export type ShareContentAuthorizationContext = {
33
+ signerDid: string;
34
+ verificationMethod: string;
35
+ claims: ShareContentAuthorizationClaims;
36
+ };
37
+ export type PresentationVerificationResult = {
38
+ checks: string[];
39
+ warnings: string[];
40
+ errors: string[];
41
+ };
42
+ export type PresentationVerifier = (token: string) => Promise<PresentationVerificationResult>;
43
+ export type ReplayStore = {
44
+ consumeOnce: (key: string, ttlSeconds: number) => Promise<boolean>;
45
+ };
46
+ export type ShareContentTrustConfig = {
47
+ enabled: boolean;
48
+ audience: string;
49
+ allowedServiceDids: readonly string[];
50
+ allowedVerificationMethods: readonly string[];
51
+ allowedAlgorithms: readonly string[];
52
+ clockSkewSeconds: number;
53
+ maxTokenTtlSeconds: number;
54
+ maxTokenBytes: number;
55
+ minJtiLength: number;
56
+ maxJtiLength: number;
57
+ };
58
+ export type ShareContentAuthorizationRejectionReason = 'DISABLED' | 'INVALID_REQUEST' | 'TOKEN_TOO_LARGE' | 'MALFORMED_TOKEN' | 'UNSUPPORTED_HEADER' | 'UNSUPPORTED_ALGORITHM' | 'MISSING_KID' | 'UNKNOWN_SIGNER' | 'UNKNOWN_VERIFICATION_METHOD' | 'SIGNATURE_INVALID' | 'SIGNER_MISMATCH' | 'MALFORMED_CLAIMS' | 'UNKNOWN_CLAIM_FIELD' | 'INVALID_CLAIMS' | 'INVALID_SHARE_ID' | 'INVALID_IDENTIFIER' | 'INVALID_JTI' | 'AUDIENCE_MISMATCH' | 'PURPOSE_MISMATCH' | 'OPERATION_NOT_ALLOWED' | 'INVALID_TTL' | 'TOKEN_EXPIRED' | 'TOKEN_NOT_YET_VALID' | 'REQUEST_BINDING_MISMATCH' | 'REQUEST_HASH_MISMATCH' | 'REPLAY_DETECTED' | 'REPLAY_STORE_UNAVAILABLE';
59
+ export type ShareContentAuthorizationResult = {
60
+ ok: true;
61
+ context: ShareContentAuthorizationContext;
62
+ } | {
63
+ ok: false;
64
+ reason: ShareContentAuthorizationRejectionReason;
65
+ };
66
+ export type ShareContentAuthorizationVerifier = {
67
+ config: ShareContentTrustConfig;
68
+ authorize: (request: ShareContentAuthorizationRequest, token: string) => Promise<ShareContentAuthorizationResult>;
69
+ };
70
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/helpers/share-content-auth/types.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,0BAA0B,EAAG,qBAA8B,CAAC;AAQzE,eAAO,MAAM,wBAAwB,2DAA4D,CAAC;AAElG,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAG9E,eAAO,MAAM,0BAA0B,qKAe7B,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAGjF,MAAM,MAAM,+BAA+B,GAAG;IAE1C,GAAG,EAAE,MAAM,CAAC;IAEZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,0BAA0B,CAAC;IAE3C,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,qBAAqB,CAAC;IAE1B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IAEvB,cAAc,EAAE,MAAM,CAAC;IAEvB,QAAQ,EAAE,MAAM,CAAC;IAEjB,WAAW,EAAE,MAAM,CAAC;IAEpB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IAEZ,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAOF,MAAM,MAAM,gCAAgC,GAAG;IAC3C,SAAS,EAAE,MA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ACjB,iBAAiB,GACjB,iBAAiB,GACjB,oBAAoB,GACpB,uBAAuB,GACvB,aAAa,GACb,gBAAgB,GAChB,6BAA6B,GAC7B,mBAAmB,GACnB,iBAAiB,GACjB,kBAAkB,GAClB,qBAAqB,GACrB,gBAAgB,GAChB,kBAAkB,GAClB,oBAAoB,GACpB,aAAa,GACb,mBAAmB,GACnB,kBAAkB,GAClB,uBAAuB,GACvB,aAAa,GACb,eAAe,GACf,qBAAqB,GACrB,0BAA0B,GAC1B,uBAAuB,GACvB,iBAAiB,GACjB,0BAA0B,CAAC;AAEjC,MAAM,MAAM,+BAA+B,GACrC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,gCAAgC,CAAA;CAAE,GACvD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,wCAAwC,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,iCAAiC,GAAG;IAC5C,MAAM,EAAE,uBAAuB,CAAC;IAChC,SAAS,EAAE,CACP,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,MAAM,KACZ,OAAO,CAAC,+BAA+B,CAAC,CAAC;CACjD,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type PresentationVerifier, type ReplayStore, type ShareContentAuthorizationVerifier, type ShareContentTrustConfig } from './types';
2
+ export type CreateShareContentAuthorizationVerifierDependencies = {
3
+ config: ShareContentTrustConfig;
4
+ verifyPresentation: PresentationVerifier;
5
+ replayStore: ReplayStore;
6
+ now?: () => number;
7
+ };
8
+ export declare const createShareContentAuthorizationVerifier: (dependencies: CreateShareContentAuthorizationVerifierDependencies) => ShareContentAuthorizationVerifier;
9
+ //# sourceMappingURL=verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifier.d.ts","sourceRoot":"","sources":["../../../src/helpers/share-content-auth/verifier.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGH,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAIhB,KAAK,iCAAiC,EACtC,KAAK,uBAAuB,EAC/B,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,mDAAmD,GAAG;IAC9D,MAAM,EAAE,uBAAuB,CAAC;IAEhC,kBAAkB,EAAE,oBAAoB,CAAC;IAEzC,WAAW,EAAE,WAAW,CAAC;IAEzB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACtB,CAAC;AAyDF,eAAO,MAAM,uCAAuC,GAChD,cAAc,mDAAmD,KAClE,iCA2HF,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/index.js
3
- size: 53107160 bytes
4
- sha256: 7d12d0e71d3b66a4b7e42a87d496e893ce4e1004b6326756af30f4d19ec87fd1
3
+ size: 53395239 bytes
4
+ sha256: 8ebe2243c876780364a730330d6e9b013db922136ba371b2bbc02af8d79d579d