aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-11-01 15:31:48 +0100
committerFlorian Dold <florian@dold.me>2022-11-01 15:31:48 +0100
commitd63a773bf5f3b74040e094a94afb732be7218106 (patch)
tree62d90758a7561bd801be5ccee19415f4a10be4e5 /packages/taler-util
parenta0305884eb58bd3cf7451eeb2774eadbb91ae138 (diff)
wallet-core: report supportedAgeGroups
Diffstat (limited to 'packages/taler-util')
-rw-r--r--packages/taler-util/src/taler-crypto.ts17
-rw-r--r--packages/taler-util/src/wallet-types.ts2
2 files changed, 19 insertions, 0 deletions
diff --git a/packages/taler-util/src/taler-crypto.ts b/packages/taler-util/src/taler-crypto.ts
index d7e9a0c06..b4b96afbc 100644
--- a/packages/taler-util/src/taler-crypto.ts
+++ b/packages/taler-util/src/taler-crypto.ts
@@ -1025,6 +1025,23 @@ export namespace AgeRestriction {
return count;
}
+ /**
+ * Get the starting points for age groups in the mask.
+ */
+ export function getAgeGroupsFromMask(mask: number): number[] {
+ const groups: number[] = [];
+ let age = 1;
+ let m = mask >> 1;
+ while (m > 0) {
+ if (m & 1) {
+ groups.push(age);
+ }
+ m = m >> 1;
+ age++;
+ }
+ return groups;
+ }
+
export function getAgeGroupIndex(mask: number, age: number): number {
invariant((mask & 1) === 1);
let i = 0;
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index f6bc13d65..3eafe7522 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -919,6 +919,7 @@ export interface ExchangeListItem {
paytoUris: string[];
tosStatus: ExchangeTosStatus;
exchangeStatus: ExchangeEntryStatus;
+ supportedAgeGroups: number[];
/**
* Permanently added to the wallet, as opposed to just
* temporarily queried.
@@ -998,6 +999,7 @@ export const codecForExchangeListItem = (): Codec<ExchangeListItem> =>
.property("tosStatus", codecForAny())
.property("exchangeStatus", codecForAny())
.property("permanent", codecForBoolean())
+ .property("supportedAgeGroups", codecForList(codecForNumber()))
.build("ExchangeListItem");
export const codecForExchangesListResponse = (): Codec<ExchangesListResponse> =>