@dereekb/util 13.11.8 → 13.11.10
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/eslint/package.json +1 -1
- package/fetch/package.json +2 -2
- package/index.cjs.js +16 -0
- package/index.esm.js +16 -0
- package/package.json +1 -1
- package/src/lib/auth/auth.role.claims.d.ts +23 -0
- package/test/package.json +2 -2
package/eslint/package.json
CHANGED
package/fetch/package.json
CHANGED
package/index.cjs.js
CHANGED
|
@@ -8889,9 +8889,25 @@ var AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE = null;
|
|
|
8889
8889
|
forEachKeyValueAddToSet(claims, roles);
|
|
8890
8890
|
return roles;
|
|
8891
8891
|
};
|
|
8892
|
+
var claimKeys = tuples.map(function(param) {
|
|
8893
|
+
var _param = _sliced_to_array$h(param, 1), key = _param[0];
|
|
8894
|
+
return key;
|
|
8895
|
+
});
|
|
8896
|
+
var copyClaims = function copyClaims(source) {
|
|
8897
|
+
var result = {};
|
|
8898
|
+
claimKeys.forEach(function(key) {
|
|
8899
|
+
var value = source[key];
|
|
8900
|
+
if (value !== undefined) {
|
|
8901
|
+
result[key] = value;
|
|
8902
|
+
}
|
|
8903
|
+
});
|
|
8904
|
+
return result;
|
|
8905
|
+
};
|
|
8892
8906
|
return {
|
|
8893
8907
|
toClaims: toClaims,
|
|
8894
8908
|
toRoles: toRoles,
|
|
8909
|
+
claimKeys: claimKeys,
|
|
8910
|
+
copyClaims: copyClaims,
|
|
8895
8911
|
defaultClaimValue: defaultClaimValue,
|
|
8896
8912
|
defaultEmptyValue: defaultEmptyValue
|
|
8897
8913
|
};
|
package/index.esm.js
CHANGED
|
@@ -8887,9 +8887,25 @@ var AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE = null;
|
|
|
8887
8887
|
forEachKeyValueAddToSet(claims, roles);
|
|
8888
8888
|
return roles;
|
|
8889
8889
|
};
|
|
8890
|
+
var claimKeys = tuples.map(function(param) {
|
|
8891
|
+
var _param = _sliced_to_array$h(param, 1), key = _param[0];
|
|
8892
|
+
return key;
|
|
8893
|
+
});
|
|
8894
|
+
var copyClaims = function copyClaims(source) {
|
|
8895
|
+
var result = {};
|
|
8896
|
+
claimKeys.forEach(function(key) {
|
|
8897
|
+
var value = source[key];
|
|
8898
|
+
if (value !== undefined) {
|
|
8899
|
+
result[key] = value;
|
|
8900
|
+
}
|
|
8901
|
+
});
|
|
8902
|
+
return result;
|
|
8903
|
+
};
|
|
8890
8904
|
return {
|
|
8891
8905
|
toClaims: toClaims,
|
|
8892
8906
|
toRoles: toRoles,
|
|
8907
|
+
claimKeys: claimKeys,
|
|
8908
|
+
copyClaims: copyClaims,
|
|
8893
8909
|
defaultClaimValue: defaultClaimValue,
|
|
8894
8910
|
defaultEmptyValue: defaultEmptyValue
|
|
8895
8911
|
};
|
package/package.json
CHANGED
|
@@ -110,12 +110,35 @@ export interface AuthRoleClaimsFactoryDefaults {
|
|
|
110
110
|
}
|
|
111
111
|
export type AuthRoleClaimsToRolesFunction<T extends AuthClaimsObject = AuthClaimsObject> = (roles: AuthRoleSet) => AuthClaimsUpdate<T>;
|
|
112
112
|
export type AuthRoleRolesToClaimsFunction<T extends AuthClaimsObject = AuthClaimsObject> = (claims: AuthClaims<T> | AuthClaimsUpdate<T>) => AuthRoleSet;
|
|
113
|
+
/**
|
|
114
|
+
* Picks the registered claim keys from a source claims object.
|
|
115
|
+
*
|
|
116
|
+
* Values that are `undefined` in the source are omitted from the result. `null` values
|
|
117
|
+
* are preserved so this also works with an {@link AuthClaimsUpdate} (where `null` means
|
|
118
|
+
* "explicitly clear"). Unknown keys on the source are ignored.
|
|
119
|
+
*/
|
|
120
|
+
export type AuthRoleClaimsCopyFunction<T extends AuthClaimsObject = AuthClaimsObject> = (source: AuthClaims<T> | AuthClaimsUpdate<T>) => AuthClaimsUpdate<T>;
|
|
113
121
|
/**
|
|
114
122
|
* Service used for converting claims to/from a roles set.
|
|
115
123
|
*/
|
|
116
124
|
export interface AuthRoleClaimsService<T extends AuthClaimsObject> {
|
|
117
125
|
readonly toClaims: AuthRoleClaimsToRolesFunction<T>;
|
|
118
126
|
readonly toRoles: AuthRoleRolesToClaimsFunction<T>;
|
|
127
|
+
/**
|
|
128
|
+
* Claim keys registered with this service (in declaration order, excluding ignored/null entries).
|
|
129
|
+
*
|
|
130
|
+
* Useful for keeping a separate list of "allowed claims" — such as an OIDC scope's claim
|
|
131
|
+
* allow-list — in sync with the service's configuration.
|
|
132
|
+
*/
|
|
133
|
+
readonly claimKeys: ReadonlyArray<keyof T & string>;
|
|
134
|
+
/**
|
|
135
|
+
* Returns a new object containing only the {@link claimKeys} present in the source.
|
|
136
|
+
*
|
|
137
|
+
* Intended for use when forwarding a subset of a user's auth claims to another system
|
|
138
|
+
* (e.g. building OIDC token claims from a Firebase Auth user record's custom claims),
|
|
139
|
+
* so the set of forwarded keys stays driven by the same registration that defines them.
|
|
140
|
+
*/
|
|
141
|
+
readonly copyClaims: AuthRoleClaimsCopyFunction<T>;
|
|
119
142
|
readonly defaultClaimValue: unknown;
|
|
120
143
|
readonly defaultEmptyValue: unknown;
|
|
121
144
|
}
|