@amedia/user 1.6.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 +20 -0
- package/package.json +1 -1
- package/user.node.d.ts +138 -3
- package/user.node.js +30 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
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
|
+
|
|
14
|
+
## 1.7.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [#1303](https://github.com/amedia/amedia-user-js/pull/1303) [`7a9bb4b`](https://github.com/amedia/amedia-user-js/commit/7a9bb4be65ff9ad8094dd2f169d254ea57b18805) Thanks [@hennikul](https://github.com/hennikul)! - Keep the session's verification set. `SessionSchema` dropped `verifications`,
|
|
19
|
+
which aID has answered since the per-class split, so a caller asking whether a
|
|
20
|
+
session proved an identity — and how recently — had only `verified_at`, the
|
|
21
|
+
newest proof of any class. `verifications[].source` is the class to branch on.
|
|
22
|
+
|
|
3
23
|
## 1.6.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/package.json
CHANGED
package/user.node.d.ts
CHANGED
|
@@ -274,6 +274,51 @@ declare const SessionSchema: Omit<v.ObjectSchema<{
|
|
|
274
274
|
readonly session_tracking_key: v.StringSchema<undefined>;
|
|
275
275
|
readonly verified_at: v.NullishSchema<v.StringSchema<undefined>, undefined>;
|
|
276
276
|
readonly verification_source: v.NullishSchema<v.StringSchema<undefined>, undefined>;
|
|
277
|
+
readonly verifications: v.ArraySchema<Omit<v.ObjectSchema<{
|
|
278
|
+
readonly source: v.StringSchema<undefined>;
|
|
279
|
+
readonly provider: v.StringSchema<undefined>;
|
|
280
|
+
readonly verified_at: v.NullishSchema<v.StringSchema<undefined>, undefined>;
|
|
281
|
+
readonly refreshed_at: v.NullishSchema<v.StringSchema<undefined>, undefined>;
|
|
282
|
+
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
283
|
+
readonly entries: {
|
|
284
|
+
readonly source: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
285
|
+
readonly provider: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
286
|
+
readonly verified_at: v.OptionalSchema<v.NullishSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
287
|
+
readonly refreshed_at: v.OptionalSchema<v.NullishSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
288
|
+
};
|
|
289
|
+
readonly "~standard": v.StandardProps<{
|
|
290
|
+
source?: string | undefined;
|
|
291
|
+
provider?: string | undefined;
|
|
292
|
+
verified_at?: string | null | undefined;
|
|
293
|
+
refreshed_at?: string | null | undefined;
|
|
294
|
+
}, {
|
|
295
|
+
source?: string | undefined;
|
|
296
|
+
provider?: string | undefined;
|
|
297
|
+
verified_at?: string | null | undefined;
|
|
298
|
+
refreshed_at?: string | null | undefined;
|
|
299
|
+
}>;
|
|
300
|
+
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
301
|
+
source?: string | undefined;
|
|
302
|
+
provider?: string | undefined;
|
|
303
|
+
verified_at?: string | null | undefined;
|
|
304
|
+
refreshed_at?: string | null | undefined;
|
|
305
|
+
}, v.StringIssue | v.ObjectIssue>;
|
|
306
|
+
readonly "~types"?: {
|
|
307
|
+
readonly input: {
|
|
308
|
+
source?: string | undefined;
|
|
309
|
+
provider?: string | undefined;
|
|
310
|
+
verified_at?: string | null | undefined;
|
|
311
|
+
refreshed_at?: string | null | undefined;
|
|
312
|
+
};
|
|
313
|
+
readonly output: {
|
|
314
|
+
source?: string | undefined;
|
|
315
|
+
provider?: string | undefined;
|
|
316
|
+
verified_at?: string | null | undefined;
|
|
317
|
+
refreshed_at?: string | null | undefined;
|
|
318
|
+
};
|
|
319
|
+
readonly issue: v.StringIssue | v.ObjectIssue;
|
|
320
|
+
} | undefined;
|
|
321
|
+
}, undefined>;
|
|
277
322
|
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
278
323
|
readonly entries: {
|
|
279
324
|
readonly user_uuid: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -281,6 +326,51 @@ declare const SessionSchema: Omit<v.ObjectSchema<{
|
|
|
281
326
|
readonly session_tracking_key: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
282
327
|
readonly verified_at: v.OptionalSchema<v.NullishSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
283
328
|
readonly verification_source: v.OptionalSchema<v.NullishSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
329
|
+
readonly verifications: v.OptionalSchema<v.ArraySchema<Omit<v.ObjectSchema<{
|
|
330
|
+
readonly source: v.StringSchema<undefined>;
|
|
331
|
+
readonly provider: v.StringSchema<undefined>;
|
|
332
|
+
readonly verified_at: v.NullishSchema<v.StringSchema<undefined>, undefined>;
|
|
333
|
+
readonly refreshed_at: v.NullishSchema<v.StringSchema<undefined>, undefined>;
|
|
334
|
+
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
335
|
+
readonly entries: {
|
|
336
|
+
readonly source: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
337
|
+
readonly provider: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
338
|
+
readonly verified_at: v.OptionalSchema<v.NullishSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
339
|
+
readonly refreshed_at: v.OptionalSchema<v.NullishSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
340
|
+
};
|
|
341
|
+
readonly "~standard": v.StandardProps<{
|
|
342
|
+
source?: string | undefined;
|
|
343
|
+
provider?: string | undefined;
|
|
344
|
+
verified_at?: string | null | undefined;
|
|
345
|
+
refreshed_at?: string | null | undefined;
|
|
346
|
+
}, {
|
|
347
|
+
source?: string | undefined;
|
|
348
|
+
provider?: string | undefined;
|
|
349
|
+
verified_at?: string | null | undefined;
|
|
350
|
+
refreshed_at?: string | null | undefined;
|
|
351
|
+
}>;
|
|
352
|
+
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
353
|
+
source?: string | undefined;
|
|
354
|
+
provider?: string | undefined;
|
|
355
|
+
verified_at?: string | null | undefined;
|
|
356
|
+
refreshed_at?: string | null | undefined;
|
|
357
|
+
}, v.StringIssue | v.ObjectIssue>;
|
|
358
|
+
readonly "~types"?: {
|
|
359
|
+
readonly input: {
|
|
360
|
+
source?: string | undefined;
|
|
361
|
+
provider?: string | undefined;
|
|
362
|
+
verified_at?: string | null | undefined;
|
|
363
|
+
refreshed_at?: string | null | undefined;
|
|
364
|
+
};
|
|
365
|
+
readonly output: {
|
|
366
|
+
source?: string | undefined;
|
|
367
|
+
provider?: string | undefined;
|
|
368
|
+
verified_at?: string | null | undefined;
|
|
369
|
+
refreshed_at?: string | null | undefined;
|
|
370
|
+
};
|
|
371
|
+
readonly issue: v.StringIssue | v.ObjectIssue;
|
|
372
|
+
} | undefined;
|
|
373
|
+
}, undefined>, undefined>;
|
|
284
374
|
};
|
|
285
375
|
readonly "~standard": v.StandardProps<{
|
|
286
376
|
user_uuid?: string | undefined;
|
|
@@ -288,12 +378,24 @@ declare const SessionSchema: Omit<v.ObjectSchema<{
|
|
|
288
378
|
session_tracking_key?: string | undefined;
|
|
289
379
|
verified_at?: string | null | undefined;
|
|
290
380
|
verification_source?: string | null | undefined;
|
|
381
|
+
verifications?: {
|
|
382
|
+
source?: string | undefined;
|
|
383
|
+
provider?: string | undefined;
|
|
384
|
+
verified_at?: string | null | undefined;
|
|
385
|
+
refreshed_at?: string | null | undefined;
|
|
386
|
+
}[] | undefined;
|
|
291
387
|
}, {
|
|
292
388
|
user_uuid?: string | undefined;
|
|
293
389
|
user_agent?: string | undefined;
|
|
294
390
|
session_tracking_key?: string | undefined;
|
|
295
391
|
verified_at?: string | null | undefined;
|
|
296
392
|
verification_source?: string | null | undefined;
|
|
393
|
+
verifications?: {
|
|
394
|
+
source?: string | undefined;
|
|
395
|
+
provider?: string | undefined;
|
|
396
|
+
verified_at?: string | null | undefined;
|
|
397
|
+
refreshed_at?: string | null | undefined;
|
|
398
|
+
}[] | undefined;
|
|
297
399
|
}>;
|
|
298
400
|
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
299
401
|
user_uuid?: string | undefined;
|
|
@@ -301,7 +403,13 @@ declare const SessionSchema: Omit<v.ObjectSchema<{
|
|
|
301
403
|
session_tracking_key?: string | undefined;
|
|
302
404
|
verified_at?: string | null | undefined;
|
|
303
405
|
verification_source?: string | null | undefined;
|
|
304
|
-
|
|
406
|
+
verifications?: {
|
|
407
|
+
source?: string | undefined;
|
|
408
|
+
provider?: string | undefined;
|
|
409
|
+
verified_at?: string | null | undefined;
|
|
410
|
+
refreshed_at?: string | null | undefined;
|
|
411
|
+
}[] | undefined;
|
|
412
|
+
}, v.StringIssue | v.ArrayIssue | v.ObjectIssue>;
|
|
305
413
|
readonly "~types"?: {
|
|
306
414
|
readonly input: {
|
|
307
415
|
user_uuid?: string | undefined;
|
|
@@ -309,6 +417,12 @@ declare const SessionSchema: Omit<v.ObjectSchema<{
|
|
|
309
417
|
session_tracking_key?: string | undefined;
|
|
310
418
|
verified_at?: string | null | undefined;
|
|
311
419
|
verification_source?: string | null | undefined;
|
|
420
|
+
verifications?: {
|
|
421
|
+
source?: string | undefined;
|
|
422
|
+
provider?: string | undefined;
|
|
423
|
+
verified_at?: string | null | undefined;
|
|
424
|
+
refreshed_at?: string | null | undefined;
|
|
425
|
+
}[] | undefined;
|
|
312
426
|
};
|
|
313
427
|
readonly output: {
|
|
314
428
|
user_uuid?: string | undefined;
|
|
@@ -316,8 +430,14 @@ declare const SessionSchema: Omit<v.ObjectSchema<{
|
|
|
316
430
|
session_tracking_key?: string | undefined;
|
|
317
431
|
verified_at?: string | null | undefined;
|
|
318
432
|
verification_source?: string | null | undefined;
|
|
433
|
+
verifications?: {
|
|
434
|
+
source?: string | undefined;
|
|
435
|
+
provider?: string | undefined;
|
|
436
|
+
verified_at?: string | null | undefined;
|
|
437
|
+
refreshed_at?: string | null | undefined;
|
|
438
|
+
}[] | undefined;
|
|
319
439
|
};
|
|
320
|
-
readonly issue: v.StringIssue | v.ObjectIssue;
|
|
440
|
+
readonly issue: v.StringIssue | v.ArrayIssue | v.ObjectIssue;
|
|
321
441
|
} | undefined;
|
|
322
442
|
};
|
|
323
443
|
type Session = v.InferOutput<typeof SessionSchema>;
|
|
@@ -517,6 +637,21 @@ declare const isLoggedOut: (value: unknown) => boolean;
|
|
|
517
637
|
*/
|
|
518
638
|
declare const namesNoReader: (value: unknown) => boolean;
|
|
519
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
|
+
|
|
520
655
|
interface AidClientOptions {
|
|
521
656
|
/** Absolute base URL for aID (e.g. "https://aid.example.no"). Required. */
|
|
522
657
|
baseUrl: string;
|
|
@@ -760,5 +895,5 @@ interface ValidatedToken {
|
|
|
760
895
|
*/
|
|
761
896
|
declare const validateToken: (jwt: string, options: ValidateTokenOptions) => Promise<ValidatedToken>;
|
|
762
897
|
|
|
763
|
-
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 };
|
|
764
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
|
@@ -128,12 +128,22 @@ const ServiceUserSchema = v.partial(v.object({
|
|
|
128
128
|
privacy_preferences: PrivacyPreferencesSchema,
|
|
129
129
|
session_tracking_key: v.string(),
|
|
130
130
|
}));
|
|
131
|
+
/** One proof a session holds. `source` is the class: `eid`, `otp` or `passkey`. */
|
|
132
|
+
const SessionVerificationSchema = v.partial(v.object({
|
|
133
|
+
source: v.string(),
|
|
134
|
+
provider: v.string(),
|
|
135
|
+
verified_at: v.nullish(v.string()),
|
|
136
|
+
refreshed_at: v.nullish(v.string()),
|
|
137
|
+
}));
|
|
131
138
|
const SessionSchema = v.partial(v.object({
|
|
132
139
|
user_uuid: v.string(),
|
|
133
140
|
user_agent: v.string(),
|
|
134
141
|
session_tracking_key: v.string(),
|
|
135
142
|
verified_at: v.nullish(v.string()),
|
|
136
143
|
verification_source: v.nullish(v.string()),
|
|
144
|
+
// A session holds one proof per class, and verified_at above is only the
|
|
145
|
+
// newest of them. Branch on verifications[].source, not on that pair.
|
|
146
|
+
verifications: v.array(SessionVerificationSchema),
|
|
137
147
|
}));
|
|
138
148
|
v.object({
|
|
139
149
|
type: v.string(),
|
|
@@ -699,6 +709,25 @@ const isLoggedOut = (value) => isAidProblem(value, ...LOGGED_OUT_PROBLEMS);
|
|
|
699
709
|
*/
|
|
700
710
|
const namesNoReader = (value) => isLoggedOut(value) || isAidProblem(value, AidProblem.MISSING_PARAMETER);
|
|
701
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
|
+
|
|
702
731
|
/**
|
|
703
732
|
* Reject URLs that are not absolute http(s) — protects against SSRF via
|
|
704
733
|
* `file:`, `gopher:`, missing scheme (empty → relative), or malformed input
|
|
@@ -997,5 +1026,5 @@ function mapJoseError(err) {
|
|
|
997
1026
|
return new ValidationError('validation_failed', String(err));
|
|
998
1027
|
}
|
|
999
1028
|
|
|
1000
|
-
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 };
|
|
1001
1030
|
//# sourceMappingURL=user.node.js.map
|