@amedia/user 1.7.0 → 1.8.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/CHANGELOG.md +23 -0
- package/README.md +5 -0
- package/package.json +1 -1
- package/user.node.d.ts +16 -1
- package/user.node.js +20 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @amedia/user
|
|
2
2
|
|
|
3
|
+
## 1.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1309](https://github.com/amedia/amedia-user-js/pull/1309) [`05602cd`](https://github.com/amedia/amedia-user-js/commit/05602cd919628e86605f41ec0d4d8d7d2f5bbf74) Thanks [@hennikul](https://github.com/hennikul)! - Check `data-aid-uuid` once per page load. Later refreshes of the reader, on
|
|
8
|
+
window focus or while polling for access, no longer compare the page, so a page
|
|
9
|
+
left open no longer reloads each time the two-minute guard expires, and markup a
|
|
10
|
+
lazy include inserts afterwards is not compared. The error logged when a page is
|
|
11
|
+
still wrong after the reload now gives `foreignElements`: the path from `body` to
|
|
12
|
+
each mismatched element, with ids, classes and sibling positions. Before reloading, the
|
|
13
|
+
reason and the same paths go to the browser console with `console.info`.
|
|
14
|
+
|
|
15
|
+
## 1.8.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#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
|
|
20
|
+
`/aid/api/users/self`, every `data-aid-uuid` on the page is compared with the
|
|
21
|
+
reader's uuid (`''` when logged out). A mismatch requests a single reload,
|
|
22
|
+
guarded per tab and URL in `sessionStorage` for two minutes so a page
|
|
23
|
+
that is still wrong cannot loop.
|
|
24
|
+
`findForeignUuids` lets a server run the same check.
|
|
25
|
+
|
|
3
26
|
## 1.7.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -213,6 +213,11 @@ the various services.
|
|
|
213
213
|
|
|
214
214
|
You should check the state object for potential emergency modes and act accordingly.
|
|
215
215
|
|
|
216
|
+
A reader can become logged in after you were told they are logged out: FedCM logs them in on the page without
|
|
217
|
+
navigating, and the module then refreshes the reader from aID. There is no separate login event. Subscribers are called
|
|
218
|
+
again and end with `state.isLoggedIn: true`; a resolved `.fetch()` never hears about it. On the way, `state` may briefly
|
|
219
|
+
lack `isLoggedIn` because the refresh clears it — treat that as "not known yet", not as logged out.
|
|
220
|
+
|
|
216
221
|
Should you wish to end your subscription, just call the returned function from `subscribe`.
|
|
217
222
|
|
|
218
223
|
#### Fetching all the data at once (no re-renders)
|
package/package.json
CHANGED
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
|