@amedia/user 1.7.0 → 1.8.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @amedia/user
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1305](https://github.com/amedia/amedia-user-js/pull/1305) [`98d79ed`](https://github.com/amedia/amedia-user-js/commit/98d79ed1ca8f7f25d9d0c62bc6f7d0700cb97ec6) Thanks [@hennikul](https://github.com/hennikul)! - Reload once when the page was rendered for another reader. After each refresh of
8
+ `/aid/api/users/self`, every `data-aid-uuid` on the page is compared with the
9
+ reader's uuid (`''` when logged out). A mismatch requests a single reload,
10
+ guarded per tab and URL in `sessionStorage` for two minutes so a page
11
+ that is still wrong cannot loop.
12
+ `findForeignUuids` lets a server run the same check.
13
+
3
14
  ## 1.7.0
4
15
 
5
16
  ### Minor Changes
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "git+https://github.com/amedia/amedia-user-js.git"
7
7
  },
8
8
  "author": "Amedia Produkt og Teknologi AS (https://amedia.no)",
9
- "version": "1.7.0",
9
+ "version": "1.8.0",
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
package/user.node.d.ts CHANGED
@@ -637,6 +637,21 @@ declare const isLoggedOut: (value: unknown) => boolean;
637
637
  */
638
638
  declare const namesNoReader: (value: unknown) => boolean;
639
639
 
640
+ /**
641
+ * The attribute a page marks user-specific markup with: the uuid of the reader
642
+ * it was rendered for, or `''` when it was rendered for no one logged in.
643
+ */
644
+ declare const PAGE_OWNER_ATTRIBUTE = "data-aid-uuid";
645
+ /**
646
+ * The marked uuids that were not rendered for `currentUuid`, deduplicated.
647
+ *
648
+ * `currentUuid` is `''` for a reader with no session, so markup rendered for a
649
+ * logged-in reader is foreign to a logged-out one, and markup rendered logged
650
+ * out is foreign to a logged-in one. Pass it only once aID has answered: a
651
+ * reader aID could not identify is unknown, not logged out.
652
+ */
653
+ declare const findForeignUuids: (currentUuid: string, markedUuids: Iterable<string>) => string[];
654
+
640
655
  interface AidClientOptions {
641
656
  /** Absolute base URL for aID (e.g. "https://aid.example.no"). Required. */
642
657
  baseUrl: string;
@@ -880,5 +895,5 @@ interface ValidatedToken {
880
895
  */
881
896
  declare const validateToken: (jwt: string, options: ValidateTokenOptions) => Promise<ValidatedToken>;
882
897
 
883
- export { AffiliationType, AidProblem, DEFAULT_CLIENT_ID, FetchTimeoutError, IgnoredNetworkError, LOGGED_OUT_PROBLEMS, LoginStatus, MAX_AGE_CEILING_SECONDS, ProblemJsonError, ResponseError, SESSION_HEADER, SITE_HEADER, ServerError, VERIFIABLE_ATTRIBUTES, VERIFICATION_SOURCES, ValidationError, buildVerificationUrl, clearJwksCache, createAidClient, createOnSiteClient, createShamoClient, fetchVerificationProviders, isAidProblem, isLoggedOut, namesNoReader, normalizeVerificationRequirement, readVerificationOutcome, validateToken, verificationSourceOf, verificationUrlFor };
898
+ export { AffiliationType, AidProblem, DEFAULT_CLIENT_ID, FetchTimeoutError, IgnoredNetworkError, LOGGED_OUT_PROBLEMS, LoginStatus, MAX_AGE_CEILING_SECONDS, PAGE_OWNER_ATTRIBUTE, ProblemJsonError, ResponseError, SESSION_HEADER, SITE_HEADER, ServerError, VERIFIABLE_ATTRIBUTES, VERIFICATION_SOURCES, ValidationError, buildVerificationUrl, clearJwksCache, createAidClient, createOnSiteClient, createShamoClient, fetchVerificationProviders, findForeignUuids, isAidProblem, isLoggedOut, namesNoReader, normalizeVerificationRequirement, readVerificationOutcome, validateToken, verificationSourceOf, verificationUrlFor };
884
899
  export type { AccessFeatures, AidClient, AidClientOptions, AidProblemType, JwksOptions, OnSiteClient, OnSiteClientOptions, PrimarySite, ServerVerificationRequirement, ServiceUser, ShamoClient, ShamoClientOptions, State, UserAttributes, ValidateTokenOptions, ValidatedToken, VerifiableAttribute, VerificationError, VerificationOutcome, VerificationProvider, VerificationRequirement, VerificationSource, VerificationStatus };
package/user.node.js CHANGED
@@ -709,6 +709,25 @@ const isLoggedOut = (value) => isAidProblem(value, ...LOGGED_OUT_PROBLEMS);
709
709
  */
710
710
  const namesNoReader = (value) => isLoggedOut(value) || isAidProblem(value, AidProblem.MISSING_PARAMETER);
711
711
 
712
+ /**
713
+ * The attribute a page marks user-specific markup with: the uuid of the reader
714
+ * it was rendered for, or `''` when it was rendered for no one logged in.
715
+ */
716
+ const PAGE_OWNER_ATTRIBUTE = 'data-aid-uuid';
717
+ const normalize = (uuid) => uuid.trim().toLowerCase();
718
+ /**
719
+ * The marked uuids that were not rendered for `currentUuid`, deduplicated.
720
+ *
721
+ * `currentUuid` is `''` for a reader with no session, so markup rendered for a
722
+ * logged-in reader is foreign to a logged-out one, and markup rendered logged
723
+ * out is foreign to a logged-in one. Pass it only once aID has answered: a
724
+ * reader aID could not identify is unknown, not logged out.
725
+ */
726
+ const findForeignUuids = (currentUuid, markedUuids) => {
727
+ const current = normalize(currentUuid);
728
+ return [...new Set(Array.from(markedUuids, normalize))].filter((uuid) => uuid !== current);
729
+ };
730
+
712
731
  /**
713
732
  * Reject URLs that are not absolute http(s) — protects against SSRF via
714
733
  * `file:`, `gopher:`, missing scheme (empty → relative), or malformed input
@@ -1007,5 +1026,5 @@ function mapJoseError(err) {
1007
1026
  return new ValidationError('validation_failed', String(err));
1008
1027
  }
1009
1028
 
1010
- export { AffiliationType, AidProblem, DEFAULT_CLIENT_ID, FetchTimeoutError, IgnoredNetworkError, LOGGED_OUT_PROBLEMS, LoginStatus, MAX_AGE_CEILING_SECONDS, ProblemJsonError, ResponseError, SESSION_HEADER, SITE_HEADER, ServerError, VERIFIABLE_ATTRIBUTES, VERIFICATION_SOURCES, ValidationError, buildVerificationUrl, clearJwksCache, createAidClient, createOnSiteClient, createShamoClient, fetchVerificationProviders, isAidProblem, isLoggedOut, namesNoReader, normalizeVerificationRequirement, readVerificationOutcome, validateToken, verificationSourceOf, verificationUrlFor };
1029
+ export { AffiliationType, AidProblem, DEFAULT_CLIENT_ID, FetchTimeoutError, IgnoredNetworkError, LOGGED_OUT_PROBLEMS, LoginStatus, MAX_AGE_CEILING_SECONDS, PAGE_OWNER_ATTRIBUTE, ProblemJsonError, ResponseError, SESSION_HEADER, SITE_HEADER, ServerError, VERIFIABLE_ATTRIBUTES, VERIFICATION_SOURCES, ValidationError, buildVerificationUrl, clearJwksCache, createAidClient, createOnSiteClient, createShamoClient, fetchVerificationProviders, findForeignUuids, isAidProblem, isLoggedOut, namesNoReader, normalizeVerificationRequirement, readVerificationOutcome, validateToken, verificationSourceOf, verificationUrlFor };
1011
1030
  //# sourceMappingURL=user.node.js.map