@owf/token-status-list 0.3.2-alpha-20260709122021 → 0.3.2-alpha-20260713153517
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/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -26
- package/dist/index.d.mts +8 -26
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -82,7 +82,8 @@ var StatusList = class StatusList {
|
|
|
82
82
|
static decompressStatusListFromBytes(compressed, bitsPerStatus, aggregationUri) {
|
|
83
83
|
try {
|
|
84
84
|
const decompressed = (0, pako.inflate)(compressed);
|
|
85
|
-
|
|
85
|
+
const statusList = StatusList.decodeStatusListFromByteArray(decompressed, bitsPerStatus);
|
|
86
|
+
return new StatusList(statusList, bitsPerStatus, aggregationUri);
|
|
86
87
|
} catch (err) {
|
|
87
88
|
throw new Error(`Decompression failed: ${err}`);
|
|
88
89
|
}
|
|
@@ -160,7 +161,8 @@ var StatusListCbor = class StatusListCbor extends _owf_cose.CborStructure {
|
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
163
|
static create(options) {
|
|
163
|
-
|
|
164
|
+
const statusList = "statusList" in options ? options.statusList : options.list instanceof Uint8Array ? StatusList.decompressStatusListFromBytes(options.list, options.bits, options.aggregationUri) : new StatusList(options.list, options.bits, options.aggregationUri);
|
|
165
|
+
return new StatusListCbor(statusList);
|
|
164
166
|
}
|
|
165
167
|
};
|
|
166
168
|
//#endregion
|
|
@@ -295,8 +297,9 @@ var StatusListCwt = class StatusListCwt {
|
|
|
295
297
|
static fromToken(token) {
|
|
296
298
|
const cwt = _owf_cose.Cwt.fromToken(token);
|
|
297
299
|
if (!cwt.payload) throw new SLException("Cwt does not contain payload, detached payload is not supported for status list CWT");
|
|
300
|
+
const payload = StatusListCwtPayload.decode(cwt.payload);
|
|
298
301
|
return new StatusListCwt({
|
|
299
|
-
payload
|
|
302
|
+
payload,
|
|
300
303
|
protectedHeaders: cwt.protectedHeaders,
|
|
301
304
|
unprotectedHeaders: cwt.unprotectedHeaders,
|
|
302
305
|
signatureOrTag: cwt.signatureOrTag
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["IdentityException","z","zUint8Array","CborStructure","TypedMap","RegisteredCwtClaimKey","z","CborStructure","TypedMap","ProtectedHeaders","UnprotectedHeaders","Cwt","RegisteredCwtClaimKey","z","zUint8Array","CborStructure","TypedMap","base64url"],"sources":["../src/status-list-exception.ts","../src/status-list.ts","../src/cbor/status-list-cbor.ts","../src/types.ts","../src/cbor/status-list-cwt-payload.ts","../src/cbor/status-list-cwt.ts","../src/cbor/status-list-info.ts","../src/fetch-status-list.ts","../src/jwt-types.ts","../src/status-list-jwt.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\n/**\n * SLException is a custom error class for Status List related exceptions.\n */\nexport class SLException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, SLException.prototype)\n this.name = 'SLException'\n }\n}\n","import { deflate, inflate } from 'pako'\nimport { SLException } from './status-list-exception'\nimport type { BitsPerStatus, StatusType } from './types'\n\n/**\n * StatusList is a class that manages a list of statuses with variable bit size.\n */\nexport class StatusList {\n private _statusList: Array<StatusType | number>\n private bitsPerStatus: BitsPerStatus\n public readonly totalStatuses: number\n public aggregationUri?: string\n\n constructor(statusList: number[], bitsPerStatus: BitsPerStatus, aggregationUri?: string) {\n if (![1, 2, 4, 8].includes(bitsPerStatus)) {\n throw new SLException('bitsPerStatus must be 1, 2, 4, or 8')\n }\n for (let i = 0; i < statusList.length; i++) {\n if (statusList[i] > 2 ** bitsPerStatus) {\n throw new SLException(`Status value out of range at index ${i} with value ${statusList[i]}`)\n }\n }\n this._statusList = statusList\n this.bitsPerStatus = bitsPerStatus\n this.totalStatuses = statusList.length\n this.aggregationUri = aggregationUri\n }\n\n /** Get the status list. */\n get statusList(): number[] {\n return this._statusList\n }\n\n /** Get the number of bits per status. */\n getBitsPerStatus(): BitsPerStatus {\n return this.bitsPerStatus\n }\n\n /** Get the status at a specific index. */\n getStatus(index: number): StatusType {\n if (index < 0 || index >= this.totalStatuses) {\n throw new Error('Index out of bounds')\n }\n return this._statusList[index]\n }\n\n /** Set the status at a specific index. */\n setStatus(index: number, value: StatusType | number): void {\n if (index < 0 || index >= this.totalStatuses) {\n throw new Error('Index out of bounds')\n }\n this._statusList[index] = value\n }\n\n /** Compress the status list and return as raw bytes. */\n compressStatusListToBytes(): Uint8Array {\n const byteArray = this.encodeStatusListIntoByteArray()\n return deflate(byteArray, { level: 9 })\n }\n\n /** Decompress a raw byte array and return a new StatusList instance. */\n static decompressStatusListFromBytes(\n compressed: Uint8Array,\n bitsPerStatus: BitsPerStatus,\n aggregationUri?: string\n ): StatusList {\n try {\n const decompressed = inflate(compressed)\n const statusList = StatusList.decodeStatusListFromByteArray(decompressed, bitsPerStatus)\n return new StatusList(statusList, bitsPerStatus, aggregationUri)\n } catch (err: unknown) {\n throw new Error(`Decompression failed: ${err}`)\n }\n }\n\n /** Encode the status list into a byte array. */\n public encodeStatusListIntoByteArray(): Uint8Array {\n const numBits = this.bitsPerStatus\n const numBytes = Math.ceil((this.totalStatuses * numBits) / 8)\n const byteArray = new Uint8Array(numBytes)\n let byteIndex = 0\n let bitIndex = 0\n let currentByte = ''\n for (let i = 0; i < this.totalStatuses; i++) {\n const status = this._statusList[i]\n currentByte = status.toString(2).padStart(numBits, '0') + currentByte\n bitIndex += numBits\n\n if (bitIndex >= 8 || i === this.totalStatuses - 1) {\n if (i === this.totalStatuses - 1 && bitIndex % 8 !== 0) {\n currentByte = currentByte.padStart(8, '0')\n }\n byteArray[byteIndex] = Number.parseInt(currentByte, 2)\n currentByte = ''\n bitIndex = 0\n byteIndex++\n }\n }\n\n return byteArray\n }\n\n /** Decode the byte array into a status list. */\n private static decodeStatusListFromByteArray(byteArray: Uint8Array, bitsPerStatus: BitsPerStatus): StatusType[] {\n const numBits = bitsPerStatus\n const totalStatuses = (byteArray.length * 8) / numBits\n const statusList = new Array<number>(totalStatuses)\n let bitIndex = 0\n for (let i = 0; i < totalStatuses; i++) {\n const byte = byteArray[Math.floor((i * numBits) / 8)]\n let byteString = byte.toString(2)\n if (byteString.length < 8) {\n byteString = '0'.repeat(8 - byteString.length) + byteString\n }\n const status = byteString.slice(bitIndex, bitIndex + numBits)\n const group = Math.floor(i / (8 / numBits))\n const indexInGroup = i % (8 / numBits)\n const position = group * (8 / numBits) + (8 / numBits + -1 - indexInGroup)\n statusList[position] = Number.parseInt(status, 2)\n bitIndex = (bitIndex + numBits) % 8\n }\n return statusList\n }\n}\n","import { CborStructure, TypedMap, typedMap, zUint8Array } from '@owf/cose'\nimport { z } from 'zod'\nimport { StatusList } from '../status-list'\nimport type { BitsPerStatus } from '../types'\n\nexport const statusListCborEncodedSchema = typedMap([\n ['bits', z.union([z.literal(1), z.literal(2), z.literal(4), z.literal(8)])],\n ['lst', zUint8Array],\n ['aggregation_uri', z.string().optional()],\n])\n\nexport const statusListCborDecodedSchema = z.instanceof(StatusList)\n\nexport type StatusListCborEncodedStructure = z.infer<typeof statusListCborEncodedSchema>\nexport type StatusListCborDecodedStructure = z.infer<typeof statusListCborDecodedSchema>\n\nexport type CreateStatusListCborOptions = {\n bits: BitsPerStatus\n list: Uint8Array | number[]\n aggregationUri?: string\n}\n\nexport type StatusListCborWithStatusListOptions = {\n statusList: StatusList\n}\n\nexport class StatusListCbor extends CborStructure<StatusListCborEncodedStructure, StatusListCborDecodedStructure> {\n public statusList = this.structure\n\n public static override get encodingSchema() {\n return z.codec(statusListCborEncodedSchema, statusListCborDecodedSchema, {\n encode: (statusList) => {\n return new TypedMap([\n ['bits', statusList.getBitsPerStatus()],\n ['lst', statusList.compressStatusListToBytes()],\n ['aggregation_uri', statusList.aggregationUri],\n ]) satisfies StatusListCborEncodedStructure\n },\n decode: (input) => {\n return StatusList.decompressStatusListFromBytes(\n input.get('lst'),\n input.get('bits'),\n input.get('aggregation_uri')\n )\n },\n })\n }\n\n public static create(options: CreateStatusListCborOptions | StatusListCborWithStatusListOptions) {\n const statusList =\n 'statusList' in options\n ? options.statusList\n : options.list instanceof Uint8Array\n ? StatusList.decompressStatusListFromBytes(options.list, options.bits, options.aggregationUri)\n : new StatusList(options.list, options.bits, options.aggregationUri)\n\n return new StatusListCbor(statusList)\n }\n}\n","// ==================== Common Types & Constants ====================\n\n/**\n * Status Type values as defined in the spec.\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-7\n */\nexport enum StatusType {\n /** The status of the Referenced Token is valid, correct or legal. */\n Valid = 0x00,\n /** The status of the Referenced Token is revoked, annulled, taken back, recalled or cancelled. */\n Invalid = 0x01,\n /** The status of the Referenced Token is temporarily invalid, hanging, debarred from privilege. */\n Suspended = 0x02,\n /** Application-specific status (0x03). */\n ApplicationSpecific3 = 0x03,\n /** Application-specific status range start (0x0C). */\n ApplicationSpecificRangeStart = 0x0c,\n /** Application-specific status range end (0x0F). */\n ApplicationSpecificRangeEnd = 0x0f,\n}\n\n/**\n * Media types for Status List Tokens\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.7\n */\nexport const MediaTypes = {\n /** Media type for JWT-based Status List Token */\n StatusListJwt: 'application/statuslist+jwt',\n /** Media type for CWT-based Status List Token */\n StatusListCwt: 'application/statuslist+cwt',\n} as const\n\n/**\n * BitsPerStatus type.\n */\nexport type BitsPerStatus = 1 | 2 | 4 | 8\n\n/**\n * Reference to a status list entry.\n */\nexport interface StatusListEntry {\n idx: number\n uri: string\n}\n","import { CborStructure, RegisteredCwtClaimKey, TypedMap, typedMap } from '@owf/cose'\nimport z from 'zod'\nimport type { StatusList } from '../status-list'\nimport { StatusListCbor, type StatusListCborEncodedStructure } from './status-list-cbor'\n\nexport enum StatusListCwtClaimKey {\n TimeToLive = 65534,\n StatusList = 65533,\n}\n\nconst statusListCwtPayloadSchema = typedMap(\n [\n [RegisteredCwtClaimKey.Subject, z.string()],\n [RegisteredCwtClaimKey.IssuedAt, z.number()],\n [RegisteredCwtClaimKey.ExpirationTime, z.number().exactOptional()],\n [StatusListCwtClaimKey.TimeToLive, z.number().exactOptional()],\n [StatusListCwtClaimKey.StatusList, z.instanceof(StatusListCbor)],\n ],\n { allowAdditionalKeys: true }\n)\n\nexport type StatusListCwtPayloadEncodedStructure = z.infer<typeof statusListCwtPayloadSchema>\nexport type StatusListCwtPayloadDecodedStructure = z.infer<typeof statusListCwtPayloadSchema>\n\nexport type CreateStatusListCwtPayloadOptions = {\n subject: string\n statusList: StatusListCbor | StatusList\n issuedAt?: Date\n expirationTime?: Date\n timeToLive?: number\n additionalClaims?: Map<number | string, unknown>\n}\n\nexport class StatusListCwtPayload extends CborStructure<\n StatusListCwtPayloadEncodedStructure,\n StatusListCwtPayloadDecodedStructure\n> {\n public static override get encodingSchema() {\n return z.codec(statusListCwtPayloadSchema.in, statusListCwtPayloadSchema.out, {\n decode: (input) => {\n const map: StatusListCwtPayloadDecodedStructure = TypedMap.fromMap(input)\n\n map.set(\n StatusListCwtClaimKey.StatusList,\n StatusListCbor.fromEncodedStructure(\n input.get(StatusListCwtClaimKey.StatusList) as StatusListCborEncodedStructure\n )\n )\n\n return map\n },\n encode: (output) => {\n const map = output.toMap() as Map<unknown, unknown>\n map.set(StatusListCwtClaimKey.StatusList, output.get(StatusListCwtClaimKey.StatusList).encodedStructure)\n return map\n },\n })\n }\n\n public static create(options: CreateStatusListCwtPayloadOptions) {\n const map = new TypedMap([\n [RegisteredCwtClaimKey.Subject, options.subject],\n [RegisteredCwtClaimKey.IssuedAt, Math.floor((options.issuedAt?.getTime() ?? Date.now()) / 1000)],\n [\n StatusListCwtClaimKey.StatusList,\n options.statusList instanceof StatusListCbor\n ? options.statusList\n : StatusListCbor.create({ statusList: options.statusList }),\n ],\n ...(options.additionalClaims ?? new Map()).entries(),\n ]) satisfies StatusListCwtPayloadEncodedStructure\n\n if (options.expirationTime) {\n map.set(RegisteredCwtClaimKey.ExpirationTime, Math.floor(options.expirationTime.getTime() / 1000))\n }\n\n if (options.timeToLive) {\n map.set(StatusListCwtClaimKey.TimeToLive, options.timeToLive)\n }\n\n return new StatusListCwtPayload(statusListCwtPayloadSchema.parse(map.toMap()))\n }\n\n public get subject() {\n return this.structure.get(RegisteredCwtClaimKey.Subject)\n }\n\n public get issuedAt() {\n return new Date(this.structure.get(RegisteredCwtClaimKey.IssuedAt) * 1000)\n }\n\n public get expirationTime() {\n return this.structure.has(RegisteredCwtClaimKey.ExpirationTime)\n ? // biome-ignore lint/style/noNonNullAssertion: checked with `has` in the line above\n new Date(this.structure.get(RegisteredCwtClaimKey.ExpirationTime)! * 1000)\n : undefined\n }\n\n public get timeToLive() {\n return this.structure.get(StatusListCwtClaimKey.TimeToLive)\n }\n\n public get statusList() {\n return this.structure.get(StatusListCwtClaimKey.StatusList).statusList\n }\n\n public getCustomClaim<ClaimType = unknown>(key: number) {\n return this.structure.get(key) as ClaimType | unknown\n }\n\n public setStatusList(statusList: StatusList | StatusListCbor) {\n this.structure.set(\n StatusListCwtClaimKey.StatusList,\n statusList instanceof StatusListCbor ? statusList : StatusListCbor.create({ statusList })\n )\n }\n}\n","import {\n type CoseKey,\n Cwt,\n type Mac0Context,\n type ProtectedHeaderOptions,\n ProtectedHeaders,\n RegisteredCwtClaimKey,\n type Sign1Context,\n type SignatureAlgorithm,\n type UnprotectedHeaderOptions,\n UnprotectedHeaders,\n} from '@owf/cose'\nimport { StatusList } from '../status-list'\nimport { SLException } from '../status-list-exception'\nimport { type BitsPerStatus, MediaTypes, StatusType } from '../types'\nimport { StatusListCbor } from './status-list-cbor'\nimport { type CreateStatusListCwtPayloadOptions, StatusListCwtPayload } from './status-list-cwt-payload'\n\nexport type StatusListCwtOptions = {\n payload: StatusListCwtPayload | CreateStatusListCwtPayloadOptions\n protectedHeaders?: ProtectedHeaders | ProtectedHeaderOptions['protectedHeaders']\n unprotectedHeaders?: UnprotectedHeaders | UnprotectedHeaderOptions['unprotectedHeaders']\n signatureOrTag?: Uint8Array\n}\n\nexport enum StatusListCwtHeaderKey {\n Typ = 16,\n}\n\nexport class StatusListCwt {\n public payload: StatusListCwtPayload\n public protectedHeaders?: ProtectedHeaders\n public unprotectedHeaders?: UnprotectedHeaders\n private signatureOrTag?: Uint8Array\n\n public constructor(options: StatusListCwtOptions) {\n this.payload =\n options.payload instanceof StatusListCwtPayload ? options.payload : StatusListCwtPayload.create(options.payload)\n this.protectedHeaders =\n options.protectedHeaders instanceof ProtectedHeaders\n ? options.protectedHeaders\n : ProtectedHeaders.create({ protectedHeaders: options.protectedHeaders })\n this.unprotectedHeaders =\n options.unprotectedHeaders instanceof UnprotectedHeaders\n ? options.unprotectedHeaders\n : UnprotectedHeaders.create({ unprotectedHeaders: options.unprotectedHeaders })\n\n this.signatureOrTag = options.signatureOrTag\n\n if (this.protectedHeaders.headers.get(StatusListCwtHeaderKey.Typ) === undefined) {\n this.protectedHeaders.headers.set(StatusListCwtHeaderKey.Typ, MediaTypes.StatusListCwt)\n }\n }\n\n public setStatusList(statusList: StatusList | StatusListCbor) {\n this.payload.setStatusList(statusList)\n }\n\n public updateStatusList(index: number, value: number) {\n this.payload.statusList.setStatus(index, value)\n }\n\n /**\n *\n * Create a minimal status list cwt. If you want to configure more options, like additional claims, use the constructor method\n *\n */\n public static createFromStatusListAndSubject(\n statusList:\n | StatusList\n | StatusListCbor\n | { statusList: number[]; bitsPerStatus: BitsPerStatus; aggregationUri?: string },\n subject: string\n ) {\n const cborStatusList =\n statusList instanceof StatusListCbor\n ? statusList\n : statusList instanceof StatusList\n ? StatusListCbor.create({ statusList })\n : StatusListCbor.create({\n bits: statusList.bitsPerStatus,\n list: statusList.statusList,\n aggregationUri: statusList.aggregationUri,\n })\n\n return new StatusListCwt({ payload: StatusListCwtPayload.create({ statusList: cborStatusList, subject }) })\n }\n\n public static fromToken(token: Uint8Array) {\n const cwt = Cwt.fromToken(token)\n\n if (!cwt.payload) {\n throw new SLException('Cwt does not contain payload, detached payload is not supported for status list CWT')\n }\n const payload = StatusListCwtPayload.decode(cwt.payload)\n\n return new StatusListCwt({\n payload,\n protectedHeaders: cwt.protectedHeaders,\n unprotectedHeaders: cwt.unprotectedHeaders,\n signatureOrTag: cwt.signatureOrTag,\n })\n }\n\n public async signAndEncode(\n options: {\n signingKey: CoseKey\n algorithm?: SignatureAlgorithm\n },\n ctx: Pick<Sign1Context, 'sign'>\n ) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n })\n return (await cwt.asSign1.sign(options, ctx)).encode()\n }\n\n public async authenticateAndEncode(options: { key: CoseKey }, ctx: Pick<Mac0Context, 'authenticate'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n })\n return (await cwt.asMac0.authenticate(options, ctx)).encode()\n }\n\n /**\n * @todo add check for `ttl` claim\n */\n public verifyStatus({\n idx,\n uri,\n checkFreshness = true,\n now = new Date(),\n }: {\n idx: number\n uri: string\n checkFreshness?: boolean\n now?: Date\n }) {\n if (this.payload.expirationTime && this.payload.expirationTime < now) {\n throw new SLException(\n `The expiration claim (${RegisteredCwtClaimKey.ExpirationTime}) '${this.payload.expirationTime}' is in the past (compared to '${now}'), and therefore not valid`\n )\n }\n if (this.payload.subject !== uri) {\n throw new SLException(\n `The subject claim (${RegisteredCwtClaimKey.Subject}) '${this.payload.subject}' must be equal to the uri '${uri}'`\n )\n }\n if (checkFreshness && this.payload.issuedAt > now) {\n throw new SLException(\n `The issued at claim (${RegisteredCwtClaimKey.IssuedAt}) '${this.payload.issuedAt}' is in the future (compared to '${now}'), and therefore not valid`\n )\n }\n if (this.payload.statusList.getStatus(idx) !== StatusType.Valid) {\n throw new SLException(\n `Status for id '${idx}' is not Valid (${StatusType.Valid}), but is instead '${this.payload.statusList.getStatus(idx)}'`\n )\n }\n }\n\n public async verifySignature({ key }: { key: CoseKey }, ctx: Pick<Sign1Context, 'verify'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n signature: this.signatureOrTag,\n })\n\n return await cwt.verifySignature({ key }, ctx)\n }\n\n public async verifyAuthenticationCode({ key }: { key: CoseKey }, ctx: Pick<Mac0Context, 'verify'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n tag: this.signatureOrTag,\n })\n\n return await cwt.verifyAuthenticationCode({ key }, ctx)\n }\n}\n","import { CborStructure, TypedMap, typedMap, zUint8Array } from '@owf/cose'\nimport { z } from 'zod'\n\n/**\n * StatusListInfo carries a reference to an IETF Token Status List\n * (draft-ietf-oauth-status-list) entry from inside the MSO's Status structure.\n *\n * Defined in ISO/IEC 18013-5 second edition (CD), 12.3.6.\n */\n// NOTE: idx is `uint` in the spec (unbounded CBOR uint). We constrain to JS\n// safe-integer range here, which is more than enough for real-world status\n// list sizes (Number.MAX_SAFE_INTEGER is ~9 × 10^15).\nconst statusListInfoSchema = typedMap([\n ['uri', z.string()],\n ['idx', z.number().int().nonnegative()],\n ['certificate', zUint8Array.exactOptional()],\n])\n\nexport type StatusListInfoDecodedStructure = z.output<typeof statusListInfoSchema>\nexport type StatusListInfoEncodedStructure = z.input<typeof statusListInfoSchema>\n\nexport type StatusListInfoOptions = {\n uri: string\n idx: number\n certificate?: Uint8Array\n}\n\nexport class StatusListInfo extends CborStructure<StatusListInfoEncodedStructure, StatusListInfoDecodedStructure> {\n public static override get encodingSchema() {\n return statusListInfoSchema\n }\n\n public get uri() {\n return this.structure.get('uri')\n }\n\n public get idx() {\n return this.structure.get('idx')\n }\n\n public get certificate() {\n return this.structure.get('certificate')\n }\n\n public static create(options: StatusListInfoOptions): StatusListInfo {\n const map: StatusListInfoDecodedStructure = new TypedMap([\n ['uri', options.uri],\n ['idx', options.idx],\n ])\n if (options.certificate) {\n map.set('certificate', options.certificate)\n }\n return StatusListInfo.fromDecodedStructure(map)\n }\n}\n","import { SLException } from './status-list-exception'\nimport { MediaTypes } from './types'\n\nexport const fetchStatusList = async ({\n uri,\n customFetcher = fetch,\n acceptedFormats = ['jwt', 'cwt'],\n}: {\n uri: string\n /**\n *\n * If none is supplied either can be returned\n *\n */\n acceptedFormats?: Array<'cwt' | 'jwt'>\n customFetcher?: typeof fetch\n}): Promise<string | Uint8Array> => {\n try {\n if (acceptedFormats.length === 0) {\n throw new SLException(`At least one accepted format (cwt, jwt) needs to be provided`)\n }\n\n const acceptHeaders = acceptedFormats.map((format) =>\n format === 'jwt' ? MediaTypes.StatusListJwt : MediaTypes.StatusListCwt\n )\n\n const response = await customFetcher(uri, {\n headers: {\n Accept: acceptHeaders.join(','),\n },\n })\n\n if (response.status > 399 || response.status <= 199) {\n throw new Error(`Could not fetch status list, response status '${response.status}'`)\n }\n\n const contentType = response.headers.get('Content-type')\n if (contentType === MediaTypes.StatusListJwt) {\n return await response.text()\n } else if (contentType === MediaTypes.StatusListCwt) {\n return await (await response.blob()).bytes()\n }\n\n throw new SLException('Content type was either not provided in the response or invalid.')\n } catch (e) {\n throw new SLException(`Could not fetch either a JWT or CWT as status list. ${(e as Error).message}`)\n }\n}\n","import type { JwtPayload } from '@owf/identity-common'\nimport type { BitsPerStatus, StatusListEntry } from './types'\n\n// ==================== JWT Types & Constants ====================\n\n/**\n * JWT type header value for Status List Token\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-5.1\n */\nexport const JWT_STATUS_LIST_TYPE = 'statuslist+jwt'\n\n/**\n * JWT claim names for Status List\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.1\n */\nexport const JWTClaimNames = {\n STATUS: 'status',\n STATUS_LIST: 'status_list',\n TTL: 'ttl',\n IDX: 'idx',\n URI: 'uri',\n BITS: 'bits',\n LST: 'lst',\n AGGREGATION_URI: 'aggregation_uri',\n} as const\n\n/**\n * Payload for a JWT with a status reference.\n */\nexport interface JWTwithStatusListPayload extends JwtPayload {\n status: {\n status_list: StatusListEntry\n }\n}\n\n/**\n * Payload for a Status List JWT.\n */\nexport interface StatusListJWTPayload extends JwtPayload {\n ttl?: number\n status_list: {\n bits: BitsPerStatus\n lst: string\n }\n}\n\n/**\n * Header parameters for a JWT Status List Token.\n */\nexport type StatusListJWTHeaderParameters = {\n alg: string\n typ: typeof JWT_STATUS_LIST_TYPE\n [key: string]: unknown\n}\n","import type { JwtPayload } from '@owf/identity-common'\nimport { base64url, bytesToString } from '@owf/identity-common'\nimport type { JWTwithStatusListPayload, StatusListJWTHeaderParameters, StatusListJWTPayload } from './jwt-types'\nimport { JWT_STATUS_LIST_TYPE } from './jwt-types'\nimport { StatusList } from './status-list'\nimport { SLException } from './status-list-exception'\nimport { type StatusListEntry, StatusType } from './types'\n\n/**\n * Decode a JWT and return the payload.\n * @param jwt JWT token in compact JWS serialization.\n */\nfunction decodeJwtPayload<T>(jwt: string): T {\n const parts = jwt.split('.')\n return JSON.parse(bytesToString(base64url.decode(parts[1])))\n}\n\n/**\n * Adds the status list to the payload and header of a JWT.\n */\nexport function createHeaderAndPayload(list: StatusList, payload: JwtPayload, header: StatusListJWTHeaderParameters) {\n if (!payload.sub) {\n throw new SLException('sub field is required')\n }\n if (!payload.iat) {\n throw new SLException('iat field is required')\n }\n\n header.typ = JWT_STATUS_LIST_TYPE\n payload.status_list = {\n bits: list.getBitsPerStatus(),\n lst: base64url.encode(list.compressStatusListToBytes()),\n }\n return { header, payload }\n}\n\n/**\n * Get the status list from a JWT, but do not verify the signature.\n */\nexport function getListFromStatusListJWT(jwt: string): StatusList {\n const payload = decodeJwtPayload<StatusListJWTPayload>(jwt)\n const statusList = payload.status_list\n const compressed = base64url.decode(statusList.lst)\n return StatusList.decompressStatusListFromBytes(compressed, statusList.bits)\n}\n\n/**\n * Get the status list entry from a JWT, but do not verify the signature.\n */\nexport function getStatusListFromJWT(jwt: string): StatusListEntry {\n const payload = decodeJwtPayload<JWTwithStatusListPayload>(jwt)\n return payload.status.status_list\n}\n\n/**\n * Verify the status of an `idx` in a `token`\n *\n * @todo properly validate the JWT with zod + signature\n */\nexport function verifyStatus({\n uri,\n idx,\n token,\n checkFreshness = true,\n now = new Date(),\n}: {\n token: string\n idx: number\n uri: string\n checkFreshness?: boolean\n now?: Date\n}) {\n const payload = decodeJwtPayload<StatusListJWTPayload>(token)\n const compressed = base64url.decode(payload.status_list.lst)\n const statusList = StatusList.decompressStatusListFromBytes(compressed, payload.status_list.bits)\n if (payload.subject !== uri) {\n throw new SLException(`The subject claim '${payload.subject}' must be equal to the uri '${uri}'`)\n }\n if (checkFreshness && payload.iat && payload.iat > Math.floor(now.getTime() / 1000)) {\n throw new SLException(\n `The issued at claim '${payload.issuedAt}' is in the future (compared to '${now}'), and therefore not valid`\n )\n }\n if (payload.exp && payload.exp < Math.floor(now.getTime() / 1000)) {\n throw new SLException(\n `The expiry claim '${payload.exp}' is in the past (compared to '${now}'), and therefore not valid`\n )\n }\n if (statusList.getStatus(idx) !== StatusType.Valid) {\n throw new SLException(\n `Status for id '${idx}' is not Valid (${StatusType.Valid}), but is instead '${statusList.getStatus(idx)}'`\n )\n }\n return true\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAa,cAAb,MAAa,oBAAoBA,qBAAAA,kBAAkB;CACjD,YAAY,SAAiB,SAAmB;EAC9C,MAAM,SAAS,OAAO;EACtB,OAAO,eAAe,MAAM,YAAY,SAAS;EACjD,KAAK,OAAO;CACd;AACF;;;;;;ACJA,IAAa,aAAb,MAAa,WAAW;CAMtB,YAAY,YAAsB,eAA8B,gBAAyB;EACvF,IAAI,CAAC;GAAC;GAAG;GAAG;GAAG;EAAC,CAAC,CAAC,SAAS,aAAa,GACtC,MAAM,IAAI,YAAY,qCA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AAM,IAAI,KAAK,KAOd;CACD,MAAM,UAAU,iBAAuC,KAAK;CAC5D,MAAM,aAAaA,qBAAAA,UAAU,OAAO,QAAQ,YAAY,GAAG;CAC3D,MAAM,aAAa,WAAW,8BAA8B,YAAY,QAAQ,YAAY,IAAI;CAChG,IAAI,QAAQ,YAAY,KACtB,MAAM,IAAI,YAAY,sBAAsB,QAAQ,QAAQ,8BAA8B,IAAI,EAAE;CAElG,IAAI,kBAAkB,QAAQ,OAAO,QAAQ,MAAM,KAAK,MAAM,IAAI,QAAQ,IAAI,GAAI,GAChF,MAAM,IAAI,YACR,wBAAwB,QAAQ,SAAS,mCAAmC,IAAI,4BAClF;CAEF,IAAI,QAAQ,OAAO,QAAQ,MAAM,KAAK,MAAM,IAAI,QAAQ,IAAI,GAAI,GAC9D,MAAM,IAAI,YACR,qBAAqB,QAAQ,IAAI,iCAAiC,IAAI,4BACxE;CAEF,IAAI,WAAW,UAAU,GAAG,MAAA,GAC1B,MAAM,IAAI,YACR,kBAAkB,IAAI,sCAAwD,WAAW,UAAU,GAAG,EAAE,EAC1G;CAEF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["IdentityException","z","zUint8Array","CborStructure","TypedMap","RegisteredCwtClaimKey","z","CborStructure","TypedMap","ProtectedHeaders","UnprotectedHeaders","Cwt","RegisteredCwtClaimKey","z","zUint8Array","CborStructure","TypedMap","base64url"],"sources":["../src/status-list-exception.ts","../src/status-list.ts","../src/cbor/status-list-cbor.ts","../src/types.ts","../src/cbor/status-list-cwt-payload.ts","../src/cbor/status-list-cwt.ts","../src/cbor/status-list-info.ts","../src/fetch-status-list.ts","../src/jwt-types.ts","../src/status-list-jwt.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\n/**\n * SLException is a custom error class for Status List related exceptions.\n */\nexport class SLException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, SLException.prototype)\n this.name = 'SLException'\n }\n}\n","import { deflate, inflate } from 'pako'\nimport { SLException } from './status-list-exception'\nimport type { BitsPerStatus, StatusType } from './types'\n\n/**\n * StatusList is a class that manages a list of statuses with variable bit size.\n */\nexport class StatusList {\n private _statusList: Array<StatusType | number>\n private bitsPerStatus: BitsPerStatus\n public readonly totalStatuses: number\n public aggregationUri?: string\n\n constructor(statusList: number[], bitsPerStatus: BitsPerStatus, aggregationUri?: string) {\n if (![1, 2, 4, 8].includes(bitsPerStatus)) {\n throw new SLException('bitsPerStatus must be 1, 2, 4, or 8')\n }\n for (let i = 0; i < statusList.length; i++) {\n if (statusList[i] > 2 ** bitsPerStatus) {\n throw new SLException(`Status value out of range at index ${i} with value ${statusList[i]}`)\n }\n }\n this._statusList = statusList\n this.bitsPerStatus = bitsPerStatus\n this.totalStatuses = statusList.length\n this.aggregationUri = aggregationUri\n }\n\n /** Get the status list. */\n get statusList(): number[] {\n return this._statusList\n }\n\n /** Get the number of bits per status. */\n getBitsPerStatus(): BitsPerStatus {\n return this.bitsPerStatus\n }\n\n /** Get the status at a specific index. */\n getStatus(index: number): StatusType {\n if (index < 0 || index >= this.totalStatuses) {\n throw new Error('Index out of bounds')\n }\n return this._statusList[index]\n }\n\n /** Set the status at a specific index. */\n setStatus(index: number, value: StatusType | number): void {\n if (index < 0 || index >= this.totalStatuses) {\n throw new Error('Index out of bounds')\n }\n this._statusList[index] = value\n }\n\n /** Compress the status list and return as raw bytes. */\n compressStatusListToBytes(): Uint8Array {\n const byteArray = this.encodeStatusListIntoByteArray()\n return deflate(byteArray, { level: 9 })\n }\n\n /** Decompress a raw byte array and return a new StatusList instance. */\n static decompressStatusListFromBytes(\n compressed: Uint8Array,\n bitsPerStatus: BitsPerStatus,\n aggregationUri?: string\n ): StatusList {\n try {\n const decompressed = inflate(compressed)\n const statusList = StatusList.decodeStatusListFromByteArray(decompressed, bitsPerStatus)\n return new StatusList(statusList, bitsPerStatus, aggregationUri)\n } catch (err: unknown) {\n throw new Error(`Decompression failed: ${err}`)\n }\n }\n\n /** Encode the status list into a byte array. */\n public encodeStatusListIntoByteArray(): Uint8Array {\n const numBits = this.bitsPerStatus\n const numBytes = Math.ceil((this.totalStatuses * numBits) / 8)\n const byteArray = new Uint8Array(numBytes)\n let byteIndex = 0\n let bitIndex = 0\n let currentByte = ''\n for (let i = 0; i < this.totalStatuses; i++) {\n const status = this._statusList[i]\n currentByte = status.toString(2).padStart(numBits, '0') + currentByte\n bitIndex += numBits\n\n if (bitIndex >= 8 || i === this.totalStatuses - 1) {\n if (i === this.totalStatuses - 1 && bitIndex % 8 !== 0) {\n currentByte = currentByte.padStart(8, '0')\n }\n byteArray[byteIndex] = Number.parseInt(currentByte, 2)\n currentByte = ''\n bitIndex = 0\n byteIndex++\n }\n }\n\n return byteArray\n }\n\n /** Decode the byte array into a status list. */\n private static decodeStatusListFromByteArray(byteArray: Uint8Array, bitsPerStatus: BitsPerStatus): StatusType[] {\n const numBits = bitsPerStatus\n const totalStatuses = (byteArray.length * 8) / numBits\n const statusList = new Array<number>(totalStatuses)\n let bitIndex = 0\n for (let i = 0; i < totalStatuses; i++) {\n const byte = byteArray[Math.floor((i * numBits) / 8)]\n let byteString = byte.toString(2)\n if (byteString.length < 8) {\n byteString = '0'.repeat(8 - byteString.length) + byteString\n }\n const status = byteString.slice(bitIndex, bitIndex + numBits)\n const group = Math.floor(i / (8 / numBits))\n const indexInGroup = i % (8 / numBits)\n const position = group * (8 / numBits) + (8 / numBits + -1 - indexInGroup)\n statusList[position] = Number.parseInt(status, 2)\n bitIndex = (bitIndex + numBits) % 8\n }\n return statusList\n }\n}\n","import { CborStructure, TypedMap, typedMap, zUint8Array } from '@owf/cose'\nimport { z } from 'zod'\nimport { StatusList } from '../status-list'\nimport type { BitsPerStatus } from '../types'\n\nexport const statusListCborEncodedSchema = typedMap([\n ['bits', z.union([z.literal(1), z.literal(2), z.literal(4), z.literal(8)])],\n ['lst', zUint8Array],\n ['aggregation_uri', z.string().optional()],\n])\n\nexport const statusListCborDecodedSchema = z.instanceof(StatusList)\n\nexport type StatusListCborEncodedStructure = z.infer<typeof statusListCborEncodedSchema>\nexport type StatusListCborDecodedStructure = z.infer<typeof statusListCborDecodedSchema>\n\nexport type CreateStatusListCborOptions = {\n bits: BitsPerStatus\n list: Uint8Array | number[]\n aggregationUri?: string\n}\n\nexport type StatusListCborWithStatusListOptions = {\n statusList: StatusList\n}\n\nexport class StatusListCbor extends CborStructure<StatusListCborEncodedStructure, StatusListCborDecodedStructure> {\n public statusList = this.structure\n\n public static override get encodingSchema() {\n return z.codec(statusListCborEncodedSchema, statusListCborDecodedSchema, {\n encode: (statusList) => {\n return new TypedMap([\n ['bits', statusList.getBitsPerStatus()],\n ['lst', statusList.compressStatusListToBytes()],\n ['aggregation_uri', statusList.aggregationUri],\n ]) satisfies StatusListCborEncodedStructure\n },\n decode: (input) => {\n return StatusList.decompressStatusListFromBytes(\n input.get('lst'),\n input.get('bits'),\n input.get('aggregation_uri')\n )\n },\n })\n }\n\n public static create(options: CreateStatusListCborOptions | StatusListCborWithStatusListOptions) {\n const statusList =\n 'statusList' in options\n ? options.statusList\n : options.list instanceof Uint8Array\n ? StatusList.decompressStatusListFromBytes(options.list, options.bits, options.aggregationUri)\n : new StatusList(options.list, options.bits, options.aggregationUri)\n\n return new StatusListCbor(statusList)\n }\n}\n","// ==================== Common Types & Constants ====================\n\n/**\n * Status Type values as defined in the spec.\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-7\n */\nexport enum StatusType {\n /** The status of the Referenced Token is valid, correct or legal. */\n Valid = 0x00,\n /** The status of the Referenced Token is revoked, annulled, taken back, recalled or cancelled. */\n Invalid = 0x01,\n /** The status of the Referenced Token is temporarily invalid, hanging, debarred from privilege. */\n Suspended = 0x02,\n /** Application-specific status (0x03). */\n ApplicationSpecific3 = 0x03,\n /** Application-specific status range start (0x0C). */\n ApplicationSpecificRangeStart = 0x0c,\n /** Application-specific status range end (0x0F). */\n ApplicationSpecificRangeEnd = 0x0f,\n}\n\n/**\n * Media types for Status List Tokens\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.7\n */\nexport const MediaTypes = {\n /** Media type for JWT-based Status List Token */\n StatusListJwt: 'application/statuslist+jwt',\n /** Media type for CWT-based Status List Token */\n StatusListCwt: 'application/statuslist+cwt',\n} as const\n\n/**\n * BitsPerStatus type.\n */\nexport type BitsPerStatus = 1 | 2 | 4 | 8\n\n/**\n * Reference to a status list entry.\n */\nexport interface StatusListEntry {\n idx: number\n uri: string\n}\n","import { CborStructure, RegisteredCwtClaimKey, TypedMap, typedMap } from '@owf/cose'\nimport z from 'zod'\nimport type { StatusList } from '../status-list'\nimport { StatusListCbor, type StatusListCborEncodedStructure } from './status-list-cbor'\n\nexport enum StatusListCwtClaimKey {\n TimeToLive = 65534,\n StatusList = 65533,\n}\n\nconst statusListCwtPayloadSchema = typedMap(\n [\n [RegisteredCwtClaimKey.Subject, z.string()],\n [RegisteredCwtClaimKey.IssuedAt, z.number()],\n [RegisteredCwtClaimKey.ExpirationTime, z.number().exactOptional()],\n [StatusListCwtClaimKey.TimeToLive, z.number().exactOptional()],\n [StatusListCwtClaimKey.StatusList, z.instanceof(StatusListCbor)],\n ],\n { allowAdditionalKeys: true }\n)\n\nexport type StatusListCwtPayloadEncodedStructure = z.infer<typeof statusListCwtPayloadSchema>\nexport type StatusListCwtPayloadDecodedStructure = z.infer<typeof statusListCwtPayloadSchema>\n\nexport type CreateStatusListCwtPayloadOptions = {\n subject: string\n statusList: StatusListCbor | StatusList\n issuedAt?: Date\n expirationTime?: Date\n timeToLive?: number\n additionalClaims?: Map<number | string, unknown>\n}\n\nexport class StatusListCwtPayload extends CborStructure<\n StatusListCwtPayloadEncodedStructure,\n StatusListCwtPayloadDecodedStructure\n> {\n public static override get encodingSchema() {\n return z.codec(statusListCwtPayloadSchema.in, statusListCwtPayloadSchema.out, {\n decode: (input) => {\n const map: StatusListCwtPayloadDecodedStructure = TypedMap.fromMap(input)\n\n map.set(\n StatusListCwtClaimKey.StatusList,\n StatusListCbor.fromEncodedStructure(\n input.get(StatusListCwtClaimKey.StatusList) as StatusListCborEncodedStructure\n )\n )\n\n return map\n },\n encode: (output) => {\n const map = output.toMap() as Map<unknown, unknown>\n map.set(StatusListCwtClaimKey.StatusList, output.get(StatusListCwtClaimKey.StatusList).encodedStructure)\n return map\n },\n })\n }\n\n public static create(options: CreateStatusListCwtPayloadOptions) {\n const map = new TypedMap([\n [RegisteredCwtClaimKey.Subject, options.subject],\n [RegisteredCwtClaimKey.IssuedAt, Math.floor((options.issuedAt?.getTime() ?? Date.now()) / 1000)],\n [\n StatusListCwtClaimKey.StatusList,\n options.statusList instanceof StatusListCbor\n ? options.statusList\n : StatusListCbor.create({ statusList: options.statusList }),\n ],\n ...(options.additionalClaims ?? new Map()).entries(),\n ]) satisfies StatusListCwtPayloadEncodedStructure\n\n if (options.expirationTime) {\n map.set(RegisteredCwtClaimKey.ExpirationTime, Math.floor(options.expirationTime.getTime() / 1000))\n }\n\n if (options.timeToLive) {\n map.set(StatusListCwtClaimKey.TimeToLive, options.timeToLive)\n }\n\n return new StatusListCwtPayload(statusListCwtPayloadSchema.parse(map.toMap()))\n }\n\n public get subject() {\n return this.structure.get(RegisteredCwtClaimKey.Subject)\n }\n\n public get issuedAt() {\n return new Date(this.structure.get(RegisteredCwtClaimKey.IssuedAt) * 1000)\n }\n\n public get expirationTime() {\n return this.structure.has(RegisteredCwtClaimKey.ExpirationTime)\n ? // biome-ignore lint/style/noNonNullAssertion: checked with `has` in the line above\n new Date(this.structure.get(RegisteredCwtClaimKey.ExpirationTime)! * 1000)\n : undefined\n }\n\n public get timeToLive() {\n return this.structure.get(StatusListCwtClaimKey.TimeToLive)\n }\n\n public get statusList() {\n return this.structure.get(StatusListCwtClaimKey.StatusList).statusList\n }\n\n public getCustomClaim<ClaimType = unknown>(key: number) {\n return this.structure.get(key) as ClaimType | unknown\n }\n\n public setStatusList(statusList: StatusList | StatusListCbor) {\n this.structure.set(\n StatusListCwtClaimKey.StatusList,\n statusList instanceof StatusListCbor ? statusList : StatusListCbor.create({ statusList })\n )\n }\n}\n","import {\n type CoseKey,\n Cwt,\n type Mac0Context,\n type ProtectedHeaderOptions,\n ProtectedHeaders,\n RegisteredCwtClaimKey,\n type Sign1Context,\n type SignatureAlgorithm,\n type UnprotectedHeaderOptions,\n UnprotectedHeaders,\n} from '@owf/cose'\nimport { StatusList } from '../status-list'\nimport { SLException } from '../status-list-exception'\nimport { type BitsPerStatus, MediaTypes, StatusType } from '../types'\nimport { StatusListCbor } from './status-list-cbor'\nimport { type CreateStatusListCwtPayloadOptions, StatusListCwtPayload } from './status-list-cwt-payload'\n\nexport type StatusListCwtOptions = {\n payload: StatusListCwtPayload | CreateStatusListCwtPayloadOptions\n protectedHeaders?: ProtectedHeaders | ProtectedHeaderOptions['protectedHeaders']\n unprotectedHeaders?: UnprotectedHeaders | UnprotectedHeaderOptions['unprotectedHeaders']\n signatureOrTag?: Uint8Array\n}\n\nexport enum StatusListCwtHeaderKey {\n Typ = 16,\n}\n\nexport class StatusListCwt {\n public payload: StatusListCwtPayload\n public protectedHeaders?: ProtectedHeaders\n public unprotectedHeaders?: UnprotectedHeaders\n private signatureOrTag?: Uint8Array\n\n public constructor(options: StatusListCwtOptions) {\n this.payload =\n options.payload instanceof StatusListCwtPayload ? options.payload : StatusListCwtPayload.create(options.payload)\n this.protectedHeaders =\n options.protectedHeaders instanceof ProtectedHeaders\n ? options.protectedHeaders\n : ProtectedHeaders.create({ protectedHeaders: options.protectedHeaders })\n this.unprotectedHeaders =\n options.unprotectedHeaders instanceof UnprotectedHeaders\n ? options.unprotectedHeaders\n : UnprotectedHeaders.create({ unprotectedHeaders: options.unprotectedHeaders })\n\n this.signatureOrTag = options.signatureOrTag\n\n if (this.protectedHeaders.headers.get(StatusListCwtHeaderKey.Typ) === undefined) {\n this.protectedHeaders.headers.set(StatusListCwtHeaderKey.Typ, MediaTypes.StatusListCwt)\n }\n }\n\n public setStatusList(statusList: StatusList | StatusListCbor) {\n this.payload.setStatusList(statusList)\n }\n\n public updateStatusList(index: number, value: number) {\n this.payload.statusList.setStatus(index, value)\n }\n\n /**\n *\n * Create a minimal status list cwt. If you want to configure more options, like additional claims, use the constructor method\n *\n */\n public static createFromStatusListAndSubject(\n statusList:\n | StatusList\n | StatusListCbor\n | { statusList: number[]; bitsPerStatus: BitsPerStatus; aggregationUri?: string },\n subject: string\n ) {\n const cborStatusList =\n statusList instanceof StatusListCbor\n ? statusList\n : statusList instanceof StatusList\n ? StatusListCbor.create({ statusList })\n : StatusListCbor.create({\n bits: statusList.bitsPerStatus,\n list: statusList.statusList,\n aggregationUri: statusList.aggregationUri,\n })\n\n return new StatusListCwt({ payload: StatusListCwtPayload.create({ statusList: cborStatusList, subject }) })\n }\n\n public static fromToken(token: Uint8Array) {\n const cwt = Cwt.fromToken(token)\n\n if (!cwt.payload) {\n throw new SLException('Cwt does not contain payload, detached payload is not supported for status list CWT')\n }\n const payload = StatusListCwtPayload.decode(cwt.payload)\n\n return new StatusListCwt({\n payload,\n protectedHeaders: cwt.protectedHeaders,\n unprotectedHeaders: cwt.unprotectedHeaders,\n signatureOrTag: cwt.signatureOrTag,\n })\n }\n\n public async signAndEncode(\n options: {\n signingKey: CoseKey\n algorithm?: SignatureAlgorithm\n },\n ctx: Pick<Sign1Context, 'sign'>\n ) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n })\n return (await cwt.asSign1.sign(options, ctx)).encode()\n }\n\n public async authenticateAndEncode(options: { key: CoseKey }, ctx: Pick<Mac0Context, 'authenticate'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n })\n return (await cwt.asMac0.authenticate(options, ctx)).encode()\n }\n\n /**\n * @todo add check for `ttl` claim\n */\n public verifyStatus({\n idx,\n uri,\n checkFreshness = true,\n now = new Date(),\n }: {\n idx: number\n uri: string\n checkFreshness?: boolean\n now?: Date\n }) {\n if (this.payload.expirationTime && this.payload.expirationTime < now) {\n throw new SLException(\n `The expiration claim (${RegisteredCwtClaimKey.ExpirationTime}) '${this.payload.expirationTime}' is in the past (compared to '${now}'), and therefore not valid`\n )\n }\n if (this.payload.subject !== uri) {\n throw new SLException(\n `The subject claim (${RegisteredCwtClaimKey.Subject}) '${this.payload.subject}' must be equal to the uri '${uri}'`\n )\n }\n if (checkFreshness && this.payload.issuedAt > now) {\n throw new SLException(\n `The issued at claim (${RegisteredCwtClaimKey.IssuedAt}) '${this.payload.issuedAt}' is in the future (compared to '${now}'), and therefore not valid`\n )\n }\n if (this.payload.statusList.getStatus(idx) !== StatusType.Valid) {\n throw new SLException(\n `Status for id '${idx}' is not Valid (${StatusType.Valid}), but is instead '${this.payload.statusList.getStatus(idx)}'`\n )\n }\n }\n\n public async verifySignature({ key }: { key: CoseKey }, ctx: Pick<Sign1Context, 'verify'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n signature: this.signatureOrTag,\n })\n\n return await cwt.verifySignature({ key }, ctx)\n }\n\n public async verifyAuthenticationCode({ key }: { key: CoseKey }, ctx: Pick<Mac0Context, 'verify'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n tag: this.signatureOrTag,\n })\n\n return await cwt.verifyAuthenticationCode({ key }, ctx)\n }\n}\n","import { CborStructure, TypedMap, typedMap, zUint8Array } from '@owf/cose'\nimport { z } from 'zod'\n\n/**\n * StatusListInfo carries a reference to an IETF Token Status List\n * (draft-ietf-oauth-status-list) entry from inside the MSO's Status structure.\n *\n * Defined in ISO/IEC 18013-5 second edition (CD), 12.3.6.\n */\n// NOTE: idx is `uint` in the spec (unbounded CBOR uint). We constrain to JS\n// safe-integer range here, which is more than enough for real-world status\n// list sizes (Number.MAX_SAFE_INTEGER is ~9 × 10^15).\nconst statusListInfoSchema = typedMap([\n ['uri', z.string()],\n ['idx', z.number().int().nonnegative()],\n ['certificate', zUint8Array.exactOptional()],\n])\n\nexport type StatusListInfoDecodedStructure = z.output<typeof statusListInfoSchema>\nexport type StatusListInfoEncodedStructure = z.input<typeof statusListInfoSchema>\n\nexport type StatusListInfoOptions = {\n uri: string\n idx: number\n certificate?: Uint8Array\n}\n\nexport class StatusListInfo extends CborStructure<StatusListInfoEncodedStructure, StatusListInfoDecodedStructure> {\n public static override get encodingSchema() {\n return statusListInfoSchema\n }\n\n public get uri() {\n return this.structure.get('uri')\n }\n\n public get idx() {\n return this.structure.get('idx')\n }\n\n public get certificate() {\n return this.structure.get('certificate')\n }\n\n public static create(options: StatusListInfoOptions): StatusListInfo {\n const map: StatusListInfoDecodedStructure = new TypedMap([\n ['uri', options.uri],\n ['idx', options.idx],\n ])\n if (options.certificate) {\n map.set('certificate', options.certificate)\n }\n return StatusListInfo.fromDecodedStructure(map)\n }\n}\n","import { SLException } from './status-list-exception'\nimport { MediaTypes } from './types'\n\nexport const fetchStatusList = async ({\n uri,\n customFetcher = fetch,\n acceptedFormats = ['jwt', 'cwt'],\n}: {\n uri: string\n /**\n *\n * If none is supplied either can be returned\n *\n */\n acceptedFormats?: Array<'cwt' | 'jwt'>\n customFetcher?: typeof fetch\n}): Promise<string | Uint8Array> => {\n try {\n if (acceptedFormats.length === 0) {\n throw new SLException(`At least one accepted format (cwt, jwt) needs to be provided`)\n }\n\n const acceptHeaders = acceptedFormats.map((format) =>\n format === 'jwt' ? MediaTypes.StatusListJwt : MediaTypes.StatusListCwt\n )\n\n const response = await customFetcher(uri, {\n headers: {\n Accept: acceptHeaders.join(','),\n },\n })\n\n if (response.status > 399 || response.status <= 199) {\n throw new Error(`Could not fetch status list, response status '${response.status}'`)\n }\n\n const contentType = response.headers.get('Content-type')\n if (contentType === MediaTypes.StatusListJwt) {\n return await response.text()\n } else if (contentType === MediaTypes.StatusListCwt) {\n return await (await response.blob()).bytes()\n }\n\n throw new SLException('Content type was either not provided in the response or invalid.')\n } catch (e) {\n throw new SLException(`Could not fetch either a JWT or CWT as status list. ${(e as Error).message}`)\n }\n}\n","import type { JwtPayload } from '@owf/identity-common'\nimport type { BitsPerStatus, StatusListEntry } from './types'\n\n// ==================== JWT Types & Constants ====================\n\n/**\n * JWT type header value for Status List Token\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-5.1\n */\nexport const JWT_STATUS_LIST_TYPE = 'statuslist+jwt'\n\n/**\n * JWT claim names for Status List\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.1\n */\nexport const JWTClaimNames = {\n STATUS: 'status',\n STATUS_LIST: 'status_list',\n TTL: 'ttl',\n IDX: 'idx',\n URI: 'uri',\n BITS: 'bits',\n LST: 'lst',\n AGGREGATION_URI: 'aggregation_uri',\n} as const\n\n/**\n * Payload for a JWT with a status reference.\n */\nexport interface JWTwithStatusListPayload extends JwtPayload {\n status: {\n status_list: StatusListEntry\n }\n}\n\n/**\n * Payload for a Status List JWT.\n */\nexport interface StatusListJWTPayload extends JwtPayload {\n ttl?: number\n status_list: {\n bits: BitsPerStatus\n lst: string\n }\n}\n\n/**\n * Header parameters for a JWT Status List Token.\n */\nexport type StatusListJWTHeaderParameters = {\n alg: string\n typ: typeof JWT_STATUS_LIST_TYPE\n [key: string]: unknown\n}\n","import type { JwtPayload } from '@owf/identity-common'\nimport { base64url, bytesToString } from '@owf/identity-common'\nimport type { JWTwithStatusListPayload, StatusListJWTHeaderParameters, StatusListJWTPayload } from './jwt-types'\nimport { JWT_STATUS_LIST_TYPE } from './jwt-types'\nimport { StatusList } from './status-list'\nimport { SLException } from './status-list-exception'\nimport { type StatusListEntry, StatusType } from './types'\n\n/**\n * Decode a JWT and return the payload.\n * @param jwt JWT token in compact JWS serialization.\n */\nfunction decodeJwtPayload<T>(jwt: string): T {\n const parts = jwt.split('.')\n return JSON.parse(bytesToString(base64url.decode(parts[1])))\n}\n\n/**\n * Adds the status list to the payload and header of a JWT.\n */\nexport function createHeaderAndPayload(list: StatusList, payload: JwtPayload, header: StatusListJWTHeaderParameters) {\n if (!payload.sub) {\n throw new SLException('sub field is required')\n }\n if (!payload.iat) {\n throw new SLException('iat field is required')\n }\n\n header.typ = JWT_STATUS_LIST_TYPE\n payload.status_list = {\n bits: list.getBitsPerStatus(),\n lst: base64url.encode(list.compressStatusListToBytes()),\n }\n return { header, payload }\n}\n\n/**\n * Get the status list from a JWT, but do not verify the signature.\n */\nexport function getListFromStatusListJWT(jwt: string): StatusList {\n const payload = decodeJwtPayload<StatusListJWTPayload>(jwt)\n const statusList = payload.status_list\n const compressed = base64url.decode(statusList.lst)\n return StatusList.decompressStatusListFromBytes(compressed, statusList.bits)\n}\n\n/**\n * Get the status list entry from a JWT, but do not verify the signature.\n */\nexport function getStatusListFromJWT(jwt: string): StatusListEntry {\n const payload = decodeJwtPayload<JWTwithStatusListPayload>(jwt)\n return payload.status.status_list\n}\n\n/**\n * Verify the status of an `idx` in a `token`\n *\n * @todo properly validate the JWT with zod + signature\n */\nexport function verifyStatus({\n uri,\n idx,\n token,\n checkFreshness = true,\n now = new Date(),\n}: {\n token: string\n idx: number\n uri: string\n checkFreshness?: boolean\n now?: Date\n}) {\n const payload = decodeJwtPayload<StatusListJWTPayload>(token)\n const compressed = base64url.decode(payload.status_list.lst)\n const statusList = StatusList.decompressStatusListFromBytes(compressed, payload.status_list.bits)\n if (payload.subject !== uri) {\n throw new SLException(`The subject claim '${payload.subject}' must be equal to the uri '${uri}'`)\n }\n if (checkFreshness && payload.iat && payload.iat > Math.floor(now.getTime() / 1000)) {\n throw new SLException(\n `The issued at claim '${payload.issuedAt}' is in the future (compared to '${now}'), and therefore not valid`\n )\n }\n if (payload.exp && payload.exp < Math.floor(now.getTime() / 1000)) {\n throw new SLException(\n `The expiry claim '${payload.exp}' is in the past (compared to '${now}'), and therefore not valid`\n )\n }\n if (statusList.getStatus(idx) !== StatusType.Valid) {\n throw new SLException(\n `Status for id '${idx}' is not Valid (${StatusType.Valid}), but is instead '${statusList.getStatus(idx)}'`\n )\n }\n return true\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAa,cAAb,MAAa,oBAAoBA,qBAAAA,kBAAkB;CACjD,YAAY,SAAiB,SAAmB;EAC9C,MAAM,SAAS,OAAO;EACtB,OAAO,eAAe,MAAM,YAAY,SAAS;EACjD,KAAK,OAAO;CACd;AACF;;;;;;ACJA,IAAa,aAAb,MAAa,WAAW;CAMtB,YAAY,YAAsB,eAA8B,gBAAyB;EACvF,IAAI,CAAC;GAAC;GAAG;GAAG;GAAG;EAAC,CAAC,CAAC,SAAS,aAAa,GACtC,MAAM,IAAI,YAAY,qCAAqC;EAE7D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KACrC,IAAI,WAAW,KAAK,KAAK,eACvB,MAAM,IAAI,YAAY,sCAAsC,EAAE,cAAc,WAAW,IAAI;EAG/F,KAAK,cAAc;EACnB,KAAK,gBAAgB;EACrB,KAAK,gBAAgB,WAAW;EAChC,KAAK,iBAAiB;CACxB;;CAGA,IAAI,aAAuB;EACzB,OAAO,KAAK;CACd;;CAGA,mBAAkC;EAChC,OAAO,KAAK;CACd;;CAGA,UAAU,OAA2B;EACnC,IAAI,QAAQ,KAAK,SAAS,KAAK,eAC7B,MAAM,IAAI,MAAM,qBAAqB;EAEvC,OAAO,KAAK,YAAY;CAC1B;;CAGA,UAAU,OAAe,OAAkC;EACzD,IAAI,QAAQ,KAAK,SAAS,KAAK,eAC7B,MAAM,IAAI,MAAM,qBAAqB;EAEvC,KAAK,YAAY,SAAS;CAC5B;;CAGA,4BAAwC;EAEtC,QAAA,GAAA,KAAA,QAAA,CADkB,KAAK,8BACA,GAAG,EAAE,OAAO,EAAE,CAAC;CACxC;;CAGA,OAAO,8BACL,YACA,eACA,gBACY;EACZ,IAAI;GACF,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EF,OAAO;AACT"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CborStructure, CoseKey, Mac0Context, ProtectedHeaderOptions, ProtectedHeaders, RegisteredCwtClaimKey, Sign1Context, SignatureAlgorithm, TypedMap, UnprotectedHeaderOptions, UnprotectedHeaders } from "@owf/cose";
|
|
2
2
|
import z, { z as z$1 } from "zod";
|
|
3
3
|
import { IdentityException, JwtPayload } from "@owf/identity-common";
|
|
4
|
-
|
|
5
4
|
//#region src/types.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Status Type values as defined in the spec.
|
|
@@ -26,7 +25,9 @@ declare enum StatusType {
|
|
|
26
25
|
* @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.7
|
|
27
26
|
*/
|
|
28
27
|
declare const MediaTypes: {
|
|
29
|
-
/** Media type for JWT-based Status List Token */
|
|
28
|
+
/** Media type for JWT-based Status List Token */
|
|
29
|
+
readonly StatusListJwt: "application/statuslist+jwt";
|
|
30
|
+
/** Media type for CWT-based Status List Token */
|
|
30
31
|
readonly StatusListCwt: "application/statuslist+cwt";
|
|
31
32
|
};
|
|
32
33
|
/**
|
|
@@ -195,25 +196,16 @@ declare class StatusListCwt {
|
|
|
195
196
|
/**
|
|
196
197
|
* @todo add check for `ttl` claim
|
|
197
198
|
*/
|
|
198
|
-
verifyStatus({
|
|
199
|
-
idx,
|
|
200
|
-
uri,
|
|
201
|
-
checkFreshness,
|
|
202
|
-
now
|
|
203
|
-
}: {
|
|
199
|
+
verifyStatus({ idx, uri, checkFreshness, now }: {
|
|
204
200
|
idx: number;
|
|
205
201
|
uri: string;
|
|
206
202
|
checkFreshness?: boolean;
|
|
207
203
|
now?: Date;
|
|
208
204
|
}): void;
|
|
209
|
-
verifySignature({
|
|
210
|
-
key
|
|
211
|
-
}: {
|
|
205
|
+
verifySignature({ key }: {
|
|
212
206
|
key: CoseKey;
|
|
213
207
|
}, ctx: Pick<Sign1Context, 'verify'>): Promise<boolean>;
|
|
214
|
-
verifyAuthenticationCode({
|
|
215
|
-
key
|
|
216
|
-
}: {
|
|
208
|
+
verifyAuthenticationCode({ key }: {
|
|
217
209
|
key: CoseKey;
|
|
218
210
|
}, ctx: Pick<Mac0Context, 'verify'>): Promise<boolean>;
|
|
219
211
|
}
|
|
@@ -258,11 +250,7 @@ declare class StatusListInfo extends CborStructure<StatusListInfoEncodedStructur
|
|
|
258
250
|
}
|
|
259
251
|
//#endregion
|
|
260
252
|
//#region src/fetch-status-list.d.ts
|
|
261
|
-
declare const fetchStatusList: ({
|
|
262
|
-
uri,
|
|
263
|
-
customFetcher,
|
|
264
|
-
acceptedFormats
|
|
265
|
-
}: {
|
|
253
|
+
declare const fetchStatusList: ({ uri, customFetcher, acceptedFormats }: {
|
|
266
254
|
uri: string;
|
|
267
255
|
/**
|
|
268
256
|
*
|
|
@@ -349,13 +337,7 @@ declare function getStatusListFromJWT(jwt: string): StatusListEntry;
|
|
|
349
337
|
*
|
|
350
338
|
* @todo properly validate the JWT with zod + signature
|
|
351
339
|
*/
|
|
352
|
-
declare function verifyStatus({
|
|
353
|
-
uri,
|
|
354
|
-
idx,
|
|
355
|
-
token,
|
|
356
|
-
checkFreshness,
|
|
357
|
-
now
|
|
358
|
-
}: {
|
|
340
|
+
declare function verifyStatus({ uri, idx, token, checkFreshness, now }: {
|
|
359
341
|
token: string;
|
|
360
342
|
idx: number;
|
|
361
343
|
uri: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CborStructure, CoseKey, Mac0Context, ProtectedHeaderOptions, ProtectedHeaders, RegisteredCwtClaimKey, Sign1Context, SignatureAlgorithm, TypedMap, UnprotectedHeaderOptions, UnprotectedHeaders } from "@owf/cose";
|
|
2
2
|
import z, { z as z$1 } from "zod";
|
|
3
3
|
import { IdentityException, JwtPayload } from "@owf/identity-common";
|
|
4
|
-
|
|
5
4
|
//#region src/types.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Status Type values as defined in the spec.
|
|
@@ -26,7 +25,9 @@ declare enum StatusType {
|
|
|
26
25
|
* @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.7
|
|
27
26
|
*/
|
|
28
27
|
declare const MediaTypes: {
|
|
29
|
-
/** Media type for JWT-based Status List Token */
|
|
28
|
+
/** Media type for JWT-based Status List Token */
|
|
29
|
+
readonly StatusListJwt: "application/statuslist+jwt";
|
|
30
|
+
/** Media type for CWT-based Status List Token */
|
|
30
31
|
readonly StatusListCwt: "application/statuslist+cwt";
|
|
31
32
|
};
|
|
32
33
|
/**
|
|
@@ -195,25 +196,16 @@ declare class StatusListCwt {
|
|
|
195
196
|
/**
|
|
196
197
|
* @todo add check for `ttl` claim
|
|
197
198
|
*/
|
|
198
|
-
verifyStatus({
|
|
199
|
-
idx,
|
|
200
|
-
uri,
|
|
201
|
-
checkFreshness,
|
|
202
|
-
now
|
|
203
|
-
}: {
|
|
199
|
+
verifyStatus({ idx, uri, checkFreshness, now }: {
|
|
204
200
|
idx: number;
|
|
205
201
|
uri: string;
|
|
206
202
|
checkFreshness?: boolean;
|
|
207
203
|
now?: Date;
|
|
208
204
|
}): void;
|
|
209
|
-
verifySignature({
|
|
210
|
-
key
|
|
211
|
-
}: {
|
|
205
|
+
verifySignature({ key }: {
|
|
212
206
|
key: CoseKey;
|
|
213
207
|
}, ctx: Pick<Sign1Context, 'verify'>): Promise<boolean>;
|
|
214
|
-
verifyAuthenticationCode({
|
|
215
|
-
key
|
|
216
|
-
}: {
|
|
208
|
+
verifyAuthenticationCode({ key }: {
|
|
217
209
|
key: CoseKey;
|
|
218
210
|
}, ctx: Pick<Mac0Context, 'verify'>): Promise<boolean>;
|
|
219
211
|
}
|
|
@@ -258,11 +250,7 @@ declare class StatusListInfo extends CborStructure<StatusListInfoEncodedStructur
|
|
|
258
250
|
}
|
|
259
251
|
//#endregion
|
|
260
252
|
//#region src/fetch-status-list.d.ts
|
|
261
|
-
declare const fetchStatusList: ({
|
|
262
|
-
uri,
|
|
263
|
-
customFetcher,
|
|
264
|
-
acceptedFormats
|
|
265
|
-
}: {
|
|
253
|
+
declare const fetchStatusList: ({ uri, customFetcher, acceptedFormats }: {
|
|
266
254
|
uri: string;
|
|
267
255
|
/**
|
|
268
256
|
*
|
|
@@ -349,13 +337,7 @@ declare function getStatusListFromJWT(jwt: string): StatusListEntry;
|
|
|
349
337
|
*
|
|
350
338
|
* @todo properly validate the JWT with zod + signature
|
|
351
339
|
*/
|
|
352
|
-
declare function verifyStatus({
|
|
353
|
-
uri,
|
|
354
|
-
idx,
|
|
355
|
-
token,
|
|
356
|
-
checkFreshness,
|
|
357
|
-
now
|
|
358
|
-
}: {
|
|
340
|
+
declare function verifyStatus({ uri, idx, token, checkFreshness, now }: {
|
|
359
341
|
token: string;
|
|
360
342
|
idx: number;
|
|
361
343
|
uri: string;
|
package/dist/index.mjs
CHANGED
|
@@ -58,7 +58,8 @@ var StatusList = class StatusList {
|
|
|
58
58
|
static decompressStatusListFromBytes(compressed, bitsPerStatus, aggregationUri) {
|
|
59
59
|
try {
|
|
60
60
|
const decompressed = inflate(compressed);
|
|
61
|
-
|
|
61
|
+
const statusList = StatusList.decodeStatusListFromByteArray(decompressed, bitsPerStatus);
|
|
62
|
+
return new StatusList(statusList, bitsPerStatus, aggregationUri);
|
|
62
63
|
} catch (err) {
|
|
63
64
|
throw new Error(`Decompression failed: ${err}`);
|
|
64
65
|
}
|
|
@@ -136,7 +137,8 @@ var StatusListCbor = class StatusListCbor extends CborStructure {
|
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
139
|
static create(options) {
|
|
139
|
-
|
|
140
|
+
const statusList = "statusList" in options ? options.statusList : options.list instanceof Uint8Array ? StatusList.decompressStatusListFromBytes(options.list, options.bits, options.aggregationUri) : new StatusList(options.list, options.bits, options.aggregationUri);
|
|
141
|
+
return new StatusListCbor(statusList);
|
|
140
142
|
}
|
|
141
143
|
};
|
|
142
144
|
//#endregion
|
|
@@ -271,8 +273,9 @@ var StatusListCwt = class StatusListCwt {
|
|
|
271
273
|
static fromToken(token) {
|
|
272
274
|
const cwt = Cwt.fromToken(token);
|
|
273
275
|
if (!cwt.payload) throw new SLException("Cwt does not contain payload, detached payload is not supported for status list CWT");
|
|
276
|
+
const payload = StatusListCwtPayload.decode(cwt.payload);
|
|
274
277
|
return new StatusListCwt({
|
|
275
|
-
payload
|
|
278
|
+
payload,
|
|
276
279
|
protectedHeaders: cwt.protectedHeaders,
|
|
277
280
|
unprotectedHeaders: cwt.unprotectedHeaders,
|
|
278
281
|
signatureOrTag: cwt.signatureOrTag
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["z","z"],"sources":["../src/status-list-exception.ts","../src/status-list.ts","../src/cbor/status-list-cbor.ts","../src/types.ts","../src/cbor/status-list-cwt-payload.ts","../src/cbor/status-list-cwt.ts","../src/cbor/status-list-info.ts","../src/fetch-status-list.ts","../src/jwt-types.ts","../src/status-list-jwt.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\n/**\n * SLException is a custom error class for Status List related exceptions.\n */\nexport class SLException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, SLException.prototype)\n this.name = 'SLException'\n }\n}\n","import { deflate, inflate } from 'pako'\nimport { SLException } from './status-list-exception'\nimport type { BitsPerStatus, StatusType } from './types'\n\n/**\n * StatusList is a class that manages a list of statuses with variable bit size.\n */\nexport class StatusList {\n private _statusList: Array<StatusType | number>\n private bitsPerStatus: BitsPerStatus\n public readonly totalStatuses: number\n public aggregationUri?: string\n\n constructor(statusList: number[], bitsPerStatus: BitsPerStatus, aggregationUri?: string) {\n if (![1, 2, 4, 8].includes(bitsPerStatus)) {\n throw new SLException('bitsPerStatus must be 1, 2, 4, or 8')\n }\n for (let i = 0; i < statusList.length; i++) {\n if (statusList[i] > 2 ** bitsPerStatus) {\n throw new SLException(`Status value out of range at index ${i} with value ${statusList[i]}`)\n }\n }\n this._statusList = statusList\n this.bitsPerStatus = bitsPerStatus\n this.totalStatuses = statusList.length\n this.aggregationUri = aggregationUri\n }\n\n /** Get the status list. */\n get statusList(): number[] {\n return this._statusList\n }\n\n /** Get the number of bits per status. */\n getBitsPerStatus(): BitsPerStatus {\n return this.bitsPerStatus\n }\n\n /** Get the status at a specific index. */\n getStatus(index: number): StatusType {\n if (index < 0 || index >= this.totalStatuses) {\n throw new Error('Index out of bounds')\n }\n return this._statusList[index]\n }\n\n /** Set the status at a specific index. */\n setStatus(index: number, value: StatusType | number): void {\n if (index < 0 || index >= this.totalStatuses) {\n throw new Error('Index out of bounds')\n }\n this._statusList[index] = value\n }\n\n /** Compress the status list and return as raw bytes. */\n compressStatusListToBytes(): Uint8Array {\n const byteArray = this.encodeStatusListIntoByteArray()\n return deflate(byteArray, { level: 9 })\n }\n\n /** Decompress a raw byte array and return a new StatusList instance. */\n static decompressStatusListFromBytes(\n compressed: Uint8Array,\n bitsPerStatus: BitsPerStatus,\n aggregationUri?: string\n ): StatusList {\n try {\n const decompressed = inflate(compressed)\n const statusList = StatusList.decodeStatusListFromByteArray(decompressed, bitsPerStatus)\n return new StatusList(statusList, bitsPerStatus, aggregationUri)\n } catch (err: unknown) {\n throw new Error(`Decompression failed: ${err}`)\n }\n }\n\n /** Encode the status list into a byte array. */\n public encodeStatusListIntoByteArray(): Uint8Array {\n const numBits = this.bitsPerStatus\n const numBytes = Math.ceil((this.totalStatuses * numBits) / 8)\n const byteArray = new Uint8Array(numBytes)\n let byteIndex = 0\n let bitIndex = 0\n let currentByte = ''\n for (let i = 0; i < this.totalStatuses; i++) {\n const status = this._statusList[i]\n currentByte = status.toString(2).padStart(numBits, '0') + currentByte\n bitIndex += numBits\n\n if (bitIndex >= 8 || i === this.totalStatuses - 1) {\n if (i === this.totalStatuses - 1 && bitIndex % 8 !== 0) {\n currentByte = currentByte.padStart(8, '0')\n }\n byteArray[byteIndex] = Number.parseInt(currentByte, 2)\n currentByte = ''\n bitIndex = 0\n byteIndex++\n }\n }\n\n return byteArray\n }\n\n /** Decode the byte array into a status list. */\n private static decodeStatusListFromByteArray(byteArray: Uint8Array, bitsPerStatus: BitsPerStatus): StatusType[] {\n const numBits = bitsPerStatus\n const totalStatuses = (byteArray.length * 8) / numBits\n const statusList = new Array<number>(totalStatuses)\n let bitIndex = 0\n for (let i = 0; i < totalStatuses; i++) {\n const byte = byteArray[Math.floor((i * numBits) / 8)]\n let byteString = byte.toString(2)\n if (byteString.length < 8) {\n byteString = '0'.repeat(8 - byteString.length) + byteString\n }\n const status = byteString.slice(bitIndex, bitIndex + numBits)\n const group = Math.floor(i / (8 / numBits))\n const indexInGroup = i % (8 / numBits)\n const position = group * (8 / numBits) + (8 / numBits + -1 - indexInGroup)\n statusList[position] = Number.parseInt(status, 2)\n bitIndex = (bitIndex + numBits) % 8\n }\n return statusList\n }\n}\n","import { CborStructure, TypedMap, typedMap, zUint8Array } from '@owf/cose'\nimport { z } from 'zod'\nimport { StatusList } from '../status-list'\nimport type { BitsPerStatus } from '../types'\n\nexport const statusListCborEncodedSchema = typedMap([\n ['bits', z.union([z.literal(1), z.literal(2), z.literal(4), z.literal(8)])],\n ['lst', zUint8Array],\n ['aggregation_uri', z.string().optional()],\n])\n\nexport const statusListCborDecodedSchema = z.instanceof(StatusList)\n\nexport type StatusListCborEncodedStructure = z.infer<typeof statusListCborEncodedSchema>\nexport type StatusListCborDecodedStructure = z.infer<typeof statusListCborDecodedSchema>\n\nexport type CreateStatusListCborOptions = {\n bits: BitsPerStatus\n list: Uint8Array | number[]\n aggregationUri?: string\n}\n\nexport type StatusListCborWithStatusListOptions = {\n statusList: StatusList\n}\n\nexport class StatusListCbor extends CborStructure<StatusListCborEncodedStructure, StatusListCborDecodedStructure> {\n public statusList = this.structure\n\n public static override get encodingSchema() {\n return z.codec(statusListCborEncodedSchema, statusListCborDecodedSchema, {\n encode: (statusList) => {\n return new TypedMap([\n ['bits', statusList.getBitsPerStatus()],\n ['lst', statusList.compressStatusListToBytes()],\n ['aggregation_uri', statusList.aggregationUri],\n ]) satisfies StatusListCborEncodedStructure\n },\n decode: (input) => {\n return StatusList.decompressStatusListFromBytes(\n input.get('lst'),\n input.get('bits'),\n input.get('aggregation_uri')\n )\n },\n })\n }\n\n public static create(options: CreateStatusListCborOptions | StatusListCborWithStatusListOptions) {\n const statusList =\n 'statusList' in options\n ? options.statusList\n : options.list instanceof Uint8Array\n ? StatusList.decompressStatusListFromBytes(options.list, options.bits, options.aggregationUri)\n : new StatusList(options.list, options.bits, options.aggregationUri)\n\n return new StatusListCbor(statusList)\n }\n}\n","// ==================== Common Types & Constants ====================\n\n/**\n * Status Type values as defined in the spec.\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-7\n */\nexport enum StatusType {\n /** The status of the Referenced Token is valid, correct or legal. */\n Valid = 0x00,\n /** The status of the Referenced Token is revoked, annulled, taken back, recalled or cancelled. */\n Invalid = 0x01,\n /** The status of the Referenced Token is temporarily invalid, hanging, debarred from privilege. */\n Suspended = 0x02,\n /** Application-specific status (0x03). */\n ApplicationSpecific3 = 0x03,\n /** Application-specific status range start (0x0C). */\n ApplicationSpecificRangeStart = 0x0c,\n /** Application-specific status range end (0x0F). */\n ApplicationSpecificRangeEnd = 0x0f,\n}\n\n/**\n * Media types for Status List Tokens\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.7\n */\nexport const MediaTypes = {\n /** Media type for JWT-based Status List Token */\n StatusListJwt: 'application/statuslist+jwt',\n /** Media type for CWT-based Status List Token */\n StatusListCwt: 'application/statuslist+cwt',\n} as const\n\n/**\n * BitsPerStatus type.\n */\nexport type BitsPerStatus = 1 | 2 | 4 | 8\n\n/**\n * Reference to a status list entry.\n */\nexport interface StatusListEntry {\n idx: number\n uri: string\n}\n","import { CborStructure, RegisteredCwtClaimKey, TypedMap, typedMap } from '@owf/cose'\nimport z from 'zod'\nimport type { StatusList } from '../status-list'\nimport { StatusListCbor, type StatusListCborEncodedStructure } from './status-list-cbor'\n\nexport enum StatusListCwtClaimKey {\n TimeToLive = 65534,\n StatusList = 65533,\n}\n\nconst statusListCwtPayloadSchema = typedMap(\n [\n [RegisteredCwtClaimKey.Subject, z.string()],\n [RegisteredCwtClaimKey.IssuedAt, z.number()],\n [RegisteredCwtClaimKey.ExpirationTime, z.number().exactOptional()],\n [StatusListCwtClaimKey.TimeToLive, z.number().exactOptional()],\n [StatusListCwtClaimKey.StatusList, z.instanceof(StatusListCbor)],\n ],\n { allowAdditionalKeys: true }\n)\n\nexport type StatusListCwtPayloadEncodedStructure = z.infer<typeof statusListCwtPayloadSchema>\nexport type StatusListCwtPayloadDecodedStructure = z.infer<typeof statusListCwtPayloadSchema>\n\nexport type CreateStatusListCwtPayloadOptions = {\n subject: string\n statusList: StatusListCbor | StatusList\n issuedAt?: Date\n expirationTime?: Date\n timeToLive?: number\n additionalClaims?: Map<number | string, unknown>\n}\n\nexport class StatusListCwtPayload extends CborStructure<\n StatusListCwtPayloadEncodedStructure,\n StatusListCwtPayloadDecodedStructure\n> {\n public static override get encodingSchema() {\n return z.codec(statusListCwtPayloadSchema.in, statusListCwtPayloadSchema.out, {\n decode: (input) => {\n const map: StatusListCwtPayloadDecodedStructure = TypedMap.fromMap(input)\n\n map.set(\n StatusListCwtClaimKey.StatusList,\n StatusListCbor.fromEncodedStructure(\n input.get(StatusListCwtClaimKey.StatusList) as StatusListCborEncodedStructure\n )\n )\n\n return map\n },\n encode: (output) => {\n const map = output.toMap() as Map<unknown, unknown>\n map.set(StatusListCwtClaimKey.StatusList, output.get(StatusListCwtClaimKey.StatusList).encodedStructure)\n return map\n },\n })\n }\n\n public static create(options: CreateStatusListCwtPayloadOptions) {\n const map = new TypedMap([\n [RegisteredCwtClaimKey.Subject, options.subject],\n [RegisteredCwtClaimKey.IssuedAt, Math.floor((options.issuedAt?.getTime() ?? Date.now()) / 1000)],\n [\n StatusListCwtClaimKey.StatusList,\n options.statusList instanceof StatusListCbor\n ? options.statusList\n : StatusListCbor.create({ statusList: options.statusList }),\n ],\n ...(options.additionalClaims ?? new Map()).entries(),\n ]) satisfies StatusListCwtPayloadEncodedStructure\n\n if (options.expirationTime) {\n map.set(RegisteredCwtClaimKey.ExpirationTime, Math.floor(options.expirationTime.getTime() / 1000))\n }\n\n if (options.timeToLive) {\n map.set(StatusListCwtClaimKey.TimeToLive, options.timeToLive)\n }\n\n return new StatusListCwtPayload(statusListCwtPayloadSchema.parse(map.toMap()))\n }\n\n public get subject() {\n return this.structure.get(RegisteredCwtClaimKey.Subject)\n }\n\n public get issuedAt() {\n return new Date(this.structure.get(RegisteredCwtClaimKey.IssuedAt) * 1000)\n }\n\n public get expirationTime() {\n return this.structure.has(RegisteredCwtClaimKey.ExpirationTime)\n ? // biome-ignore lint/style/noNonNullAssertion: checked with `has` in the line above\n new Date(this.structure.get(RegisteredCwtClaimKey.ExpirationTime)! * 1000)\n : undefined\n }\n\n public get timeToLive() {\n return this.structure.get(StatusListCwtClaimKey.TimeToLive)\n }\n\n public get statusList() {\n return this.structure.get(StatusListCwtClaimKey.StatusList).statusList\n }\n\n public getCustomClaim<ClaimType = unknown>(key: number) {\n return this.structure.get(key) as ClaimType | unknown\n }\n\n public setStatusList(statusList: StatusList | StatusListCbor) {\n this.structure.set(\n StatusListCwtClaimKey.StatusList,\n statusList instanceof StatusListCbor ? statusList : StatusListCbor.create({ statusList })\n )\n }\n}\n","import {\n type CoseKey,\n Cwt,\n type Mac0Context,\n type ProtectedHeaderOptions,\n ProtectedHeaders,\n RegisteredCwtClaimKey,\n type Sign1Context,\n type SignatureAlgorithm,\n type UnprotectedHeaderOptions,\n UnprotectedHeaders,\n} from '@owf/cose'\nimport { StatusList } from '../status-list'\nimport { SLException } from '../status-list-exception'\nimport { type BitsPerStatus, MediaTypes, StatusType } from '../types'\nimport { StatusListCbor } from './status-list-cbor'\nimport { type CreateStatusListCwtPayloadOptions, StatusListCwtPayload } from './status-list-cwt-payload'\n\nexport type StatusListCwtOptions = {\n payload: StatusListCwtPayload | CreateStatusListCwtPayloadOptions\n protectedHeaders?: ProtectedHeaders | ProtectedHeaderOptions['protectedHeaders']\n unprotectedHeaders?: UnprotectedHeaders | UnprotectedHeaderOptions['unprotectedHeaders']\n signatureOrTag?: Uint8Array\n}\n\nexport enum StatusListCwtHeaderKey {\n Typ = 16,\n}\n\nexport class StatusListCwt {\n public payload: StatusListCwtPayload\n public protectedHeaders?: ProtectedHeaders\n public unprotectedHeaders?: UnprotectedHeaders\n private signatureOrTag?: Uint8Array\n\n public constructor(options: StatusListCwtOptions) {\n this.payload =\n options.payload instanceof StatusListCwtPayload ? options.payload : StatusListCwtPayload.create(options.payload)\n this.protectedHeaders =\n options.protectedHeaders instanceof ProtectedHeaders\n ? options.protectedHeaders\n : ProtectedHeaders.create({ protectedHeaders: options.protectedHeaders })\n this.unprotectedHeaders =\n options.unprotectedHeaders instanceof UnprotectedHeaders\n ? options.unprotectedHeaders\n : UnprotectedHeaders.create({ unprotectedHeaders: options.unprotectedHeaders })\n\n this.signatureOrTag = options.signatureOrTag\n\n if (this.protectedHeaders.headers.get(StatusListCwtHeaderKey.Typ) === undefined) {\n this.protectedHeaders.headers.set(StatusListCwtHeaderKey.Typ, MediaTypes.StatusListCwt)\n }\n }\n\n public setStatusList(statusList: StatusList | StatusListCbor) {\n this.payload.setStatusList(statusList)\n }\n\n public updateStatusList(index: number, value: number) {\n this.payload.statusList.setStatus(index, value)\n }\n\n /**\n *\n * Create a minimal status list cwt. If you want to configure more options, like additional claims, use the constructor method\n *\n */\n public static createFromStatusListAndSubject(\n statusList:\n | StatusList\n | StatusListCbor\n | { statusList: number[]; bitsPerStatus: BitsPerStatus; aggregationUri?: string },\n subject: string\n ) {\n const cborStatusList =\n statusList instanceof StatusListCbor\n ? statusList\n : statusList instanceof StatusList\n ? StatusListCbor.create({ statusList })\n : StatusListCbor.create({\n bits: statusList.bitsPerStatus,\n list: statusList.statusList,\n aggregationUri: statusList.aggregationUri,\n })\n\n return new StatusListCwt({ payload: StatusListCwtPayload.create({ statusList: cborStatusList, subject }) })\n }\n\n public static fromToken(token: Uint8Array) {\n const cwt = Cwt.fromToken(token)\n\n if (!cwt.payload) {\n throw new SLException('Cwt does not contain payload, detached payload is not supported for status list CWT')\n }\n const payload = StatusListCwtPayload.decode(cwt.payload)\n\n return new StatusListCwt({\n payload,\n protectedHeaders: cwt.protectedHeaders,\n unprotectedHeaders: cwt.unprotectedHeaders,\n signatureOrTag: cwt.signatureOrTag,\n })\n }\n\n public async signAndEncode(\n options: {\n signingKey: CoseKey\n algorithm?: SignatureAlgorithm\n },\n ctx: Pick<Sign1Context, 'sign'>\n ) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n })\n return (await cwt.asSign1.sign(options, ctx)).encode()\n }\n\n public async authenticateAndEncode(options: { key: CoseKey }, ctx: Pick<Mac0Context, 'authenticate'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n })\n return (await cwt.asMac0.authenticate(options, ctx)).encode()\n }\n\n /**\n * @todo add check for `ttl` claim\n */\n public verifyStatus({\n idx,\n uri,\n checkFreshness = true,\n now = new Date(),\n }: {\n idx: number\n uri: string\n checkFreshness?: boolean\n now?: Date\n }) {\n if (this.payload.expirationTime && this.payload.expirationTime < now) {\n throw new SLException(\n `The expiration claim (${RegisteredCwtClaimKey.ExpirationTime}) '${this.payload.expirationTime}' is in the past (compared to '${now}'), and therefore not valid`\n )\n }\n if (this.payload.subject !== uri) {\n throw new SLException(\n `The subject claim (${RegisteredCwtClaimKey.Subject}) '${this.payload.subject}' must be equal to the uri '${uri}'`\n )\n }\n if (checkFreshness && this.payload.issuedAt > now) {\n throw new SLException(\n `The issued at claim (${RegisteredCwtClaimKey.IssuedAt}) '${this.payload.issuedAt}' is in the future (compared to '${now}'), and therefore not valid`\n )\n }\n if (this.payload.statusList.getStatus(idx) !== StatusType.Valid) {\n throw new SLException(\n `Status for id '${idx}' is not Valid (${StatusType.Valid}), but is instead '${this.payload.statusList.getStatus(idx)}'`\n )\n }\n }\n\n public async verifySignature({ key }: { key: CoseKey }, ctx: Pick<Sign1Context, 'verify'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n signature: this.signatureOrTag,\n })\n\n return await cwt.verifySignature({ key }, ctx)\n }\n\n public async verifyAuthenticationCode({ key }: { key: CoseKey }, ctx: Pick<Mac0Context, 'verify'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n tag: this.signatureOrTag,\n })\n\n return await cwt.verifyAuthenticationCode({ key }, ctx)\n }\n}\n","import { CborStructure, TypedMap, typedMap, zUint8Array } from '@owf/cose'\nimport { z } from 'zod'\n\n/**\n * StatusListInfo carries a reference to an IETF Token Status List\n * (draft-ietf-oauth-status-list) entry from inside the MSO's Status structure.\n *\n * Defined in ISO/IEC 18013-5 second edition (CD), 12.3.6.\n */\n// NOTE: idx is `uint` in the spec (unbounded CBOR uint). We constrain to JS\n// safe-integer range here, which is more than enough for real-world status\n// list sizes (Number.MAX_SAFE_INTEGER is ~9 × 10^15).\nconst statusListInfoSchema = typedMap([\n ['uri', z.string()],\n ['idx', z.number().int().nonnegative()],\n ['certificate', zUint8Array.exactOptional()],\n])\n\nexport type StatusListInfoDecodedStructure = z.output<typeof statusListInfoSchema>\nexport type StatusListInfoEncodedStructure = z.input<typeof statusListInfoSchema>\n\nexport type StatusListInfoOptions = {\n uri: string\n idx: number\n certificate?: Uint8Array\n}\n\nexport class StatusListInfo extends CborStructure<StatusListInfoEncodedStructure, StatusListInfoDecodedStructure> {\n public static override get encodingSchema() {\n return statusListInfoSchema\n }\n\n public get uri() {\n return this.structure.get('uri')\n }\n\n public get idx() {\n return this.structure.get('idx')\n }\n\n public get certificate() {\n return this.structure.get('certificate')\n }\n\n public static create(options: StatusListInfoOptions): StatusListInfo {\n const map: StatusListInfoDecodedStructure = new TypedMap([\n ['uri', options.uri],\n ['idx', options.idx],\n ])\n if (options.certificate) {\n map.set('certificate', options.certificate)\n }\n return StatusListInfo.fromDecodedStructure(map)\n }\n}\n","import { SLException } from './status-list-exception'\nimport { MediaTypes } from './types'\n\nexport const fetchStatusList = async ({\n uri,\n customFetcher = fetch,\n acceptedFormats = ['jwt', 'cwt'],\n}: {\n uri: string\n /**\n *\n * If none is supplied either can be returned\n *\n */\n acceptedFormats?: Array<'cwt' | 'jwt'>\n customFetcher?: typeof fetch\n}): Promise<string | Uint8Array> => {\n try {\n if (acceptedFormats.length === 0) {\n throw new SLException(`At least one accepted format (cwt, jwt) needs to be provided`)\n }\n\n const acceptHeaders = acceptedFormats.map((format) =>\n format === 'jwt' ? MediaTypes.StatusListJwt : MediaTypes.StatusListCwt\n )\n\n const response = await customFetcher(uri, {\n headers: {\n Accept: acceptHeaders.join(','),\n },\n })\n\n if (response.status > 399 || response.status <= 199) {\n throw new Error(`Could not fetch status list, response status '${response.status}'`)\n }\n\n const contentType = response.headers.get('Content-type')\n if (contentType === MediaTypes.StatusListJwt) {\n return await response.text()\n } else if (contentType === MediaTypes.StatusListCwt) {\n return await (await response.blob()).bytes()\n }\n\n throw new SLException('Content type was either not provided in the response or invalid.')\n } catch (e) {\n throw new SLException(`Could not fetch either a JWT or CWT as status list. ${(e as Error).message}`)\n }\n}\n","import type { JwtPayload } from '@owf/identity-common'\nimport type { BitsPerStatus, StatusListEntry } from './types'\n\n// ==================== JWT Types & Constants ====================\n\n/**\n * JWT type header value for Status List Token\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-5.1\n */\nexport const JWT_STATUS_LIST_TYPE = 'statuslist+jwt'\n\n/**\n * JWT claim names for Status List\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.1\n */\nexport const JWTClaimNames = {\n STATUS: 'status',\n STATUS_LIST: 'status_list',\n TTL: 'ttl',\n IDX: 'idx',\n URI: 'uri',\n BITS: 'bits',\n LST: 'lst',\n AGGREGATION_URI: 'aggregation_uri',\n} as const\n\n/**\n * Payload for a JWT with a status reference.\n */\nexport interface JWTwithStatusListPayload extends JwtPayload {\n status: {\n status_list: StatusListEntry\n }\n}\n\n/**\n * Payload for a Status List JWT.\n */\nexport interface StatusListJWTPayload extends JwtPayload {\n ttl?: number\n status_list: {\n bits: BitsPerStatus\n lst: string\n }\n}\n\n/**\n * Header parameters for a JWT Status List Token.\n */\nexport type StatusListJWTHeaderParameters = {\n alg: string\n typ: typeof JWT_STATUS_LIST_TYPE\n [key: string]: unknown\n}\n","import type { JwtPayload } from '@owf/identity-common'\nimport { base64url, bytesToString } from '@owf/identity-common'\nimport type { JWTwithStatusListPayload, StatusListJWTHeaderParameters, StatusListJWTPayload } from './jwt-types'\nimport { JWT_STATUS_LIST_TYPE } from './jwt-types'\nimport { StatusList } from './status-list'\nimport { SLException } from './status-list-exception'\nimport { type StatusListEntry, StatusType } from './types'\n\n/**\n * Decode a JWT and return the payload.\n * @param jwt JWT token in compact JWS serialization.\n */\nfunction decodeJwtPayload<T>(jwt: string): T {\n const parts = jwt.split('.')\n return JSON.parse(bytesToString(base64url.decode(parts[1])))\n}\n\n/**\n * Adds the status list to the payload and header of a JWT.\n */\nexport function createHeaderAndPayload(list: StatusList, payload: JwtPayload, header: StatusListJWTHeaderParameters) {\n if (!payload.sub) {\n throw new SLException('sub field is required')\n }\n if (!payload.iat) {\n throw new SLException('iat field is required')\n }\n\n header.typ = JWT_STATUS_LIST_TYPE\n payload.status_list = {\n bits: list.getBitsPerStatus(),\n lst: base64url.encode(list.compressStatusListToBytes()),\n }\n return { header, payload }\n}\n\n/**\n * Get the status list from a JWT, but do not verify the signature.\n */\nexport function getListFromStatusListJWT(jwt: string): StatusList {\n const payload = decodeJwtPayload<StatusListJWTPayload>(jwt)\n const statusList = payload.status_list\n const compressed = base64url.decode(statusList.lst)\n return StatusList.decompressStatusListFromBytes(compressed, statusList.bits)\n}\n\n/**\n * Get the status list entry from a JWT, but do not verify the signature.\n */\nexport function getStatusListFromJWT(jwt: string): StatusListEntry {\n const payload = decodeJwtPayload<JWTwithStatusListPayload>(jwt)\n return payload.status.status_list\n}\n\n/**\n * Verify the status of an `idx` in a `token`\n *\n * @todo properly validate the JWT with zod + signature\n */\nexport function verifyStatus({\n uri,\n idx,\n token,\n checkFreshness = true,\n now = new Date(),\n}: {\n token: string\n idx: number\n uri: string\n checkFreshness?: boolean\n now?: Date\n}) {\n const payload = decodeJwtPayload<StatusListJWTPayload>(token)\n const compressed = base64url.decode(payload.status_list.lst)\n const statusList = StatusList.decompressStatusListFromBytes(compressed, payload.status_list.bits)\n if (payload.subject !== uri) {\n throw new SLException(`The subject claim '${payload.subject}' must be equal to the uri '${uri}'`)\n }\n if (checkFreshness && payload.iat && payload.iat > Math.floor(now.getTime() / 1000)) {\n throw new SLException(\n `The issued at claim '${payload.issuedAt}' is in the future (compared to '${now}'), and therefore not valid`\n )\n }\n if (payload.exp && payload.exp < Math.floor(now.getTime() / 1000)) {\n throw new SLException(\n `The expiry claim '${payload.exp}' is in the past (compared to '${now}'), and therefore not valid`\n )\n }\n if (statusList.getStatus(idx) !== StatusType.Valid) {\n throw new SLException(\n `Status for id '${idx}' is not Valid (${StatusType.Valid}), but is instead '${statusList.getStatus(idx)}'`\n )\n }\n return true\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,cAAb,MAAa,oBAAoB,kBAAkB;CACjD,YAAY,SAAiB,SAAmB;EAC9C,MAAM,SAAS,OAAO;EACtB,OAAO,eAAe,MAAM,YAAY,SAAS;EACjD,KAAK,OAAO;CACd;AACF;;;;;;ACJA,IAAa,aAAb,MAAa,WAAW;CAMtB,YAAY,YAAsB,eAA8B,gBAAyB;EACvF,IAAI,CAAC;GAAC;GAAG;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AK,MAAM,IAAI,QAAQ,IAAI,GAAI,GAC9D,MAAM,IAAI,YACR,qBAAqB,QAAQ,IAAI,iCAAiC,IAAI,4BACxE;CAEF,IAAI,WAAW,UAAU,GAAG,MAAA,GAC1B,MAAM,IAAI,YACR,kBAAkB,IAAI,sCAAwD,WAAW,UAAU,GAAG,EAAE,EAC1G;CAEF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["z","z"],"sources":["../src/status-list-exception.ts","../src/status-list.ts","../src/cbor/status-list-cbor.ts","../src/types.ts","../src/cbor/status-list-cwt-payload.ts","../src/cbor/status-list-cwt.ts","../src/cbor/status-list-info.ts","../src/fetch-status-list.ts","../src/jwt-types.ts","../src/status-list-jwt.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\n/**\n * SLException is a custom error class for Status List related exceptions.\n */\nexport class SLException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, SLException.prototype)\n this.name = 'SLException'\n }\n}\n","import { deflate, inflate } from 'pako'\nimport { SLException } from './status-list-exception'\nimport type { BitsPerStatus, StatusType } from './types'\n\n/**\n * StatusList is a class that manages a list of statuses with variable bit size.\n */\nexport class StatusList {\n private _statusList: Array<StatusType | number>\n private bitsPerStatus: BitsPerStatus\n public readonly totalStatuses: number\n public aggregationUri?: string\n\n constructor(statusList: number[], bitsPerStatus: BitsPerStatus, aggregationUri?: string) {\n if (![1, 2, 4, 8].includes(bitsPerStatus)) {\n throw new SLException('bitsPerStatus must be 1, 2, 4, or 8')\n }\n for (let i = 0; i < statusList.length; i++) {\n if (statusList[i] > 2 ** bitsPerStatus) {\n throw new SLException(`Status value out of range at index ${i} with value ${statusList[i]}`)\n }\n }\n this._statusList = statusList\n this.bitsPerStatus = bitsPerStatus\n this.totalStatuses = statusList.length\n this.aggregationUri = aggregationUri\n }\n\n /** Get the status list. */\n get statusList(): number[] {\n return this._statusList\n }\n\n /** Get the number of bits per status. */\n getBitsPerStatus(): BitsPerStatus {\n return this.bitsPerStatus\n }\n\n /** Get the status at a specific index. */\n getStatus(index: number): StatusType {\n if (index < 0 || index >= this.totalStatuses) {\n throw new Error('Index out of bounds')\n }\n return this._statusList[index]\n }\n\n /** Set the status at a specific index. */\n setStatus(index: number, value: StatusType | number): void {\n if (index < 0 || index >= this.totalStatuses) {\n throw new Error('Index out of bounds')\n }\n this._statusList[index] = value\n }\n\n /** Compress the status list and return as raw bytes. */\n compressStatusListToBytes(): Uint8Array {\n const byteArray = this.encodeStatusListIntoByteArray()\n return deflate(byteArray, { level: 9 })\n }\n\n /** Decompress a raw byte array and return a new StatusList instance. */\n static decompressStatusListFromBytes(\n compressed: Uint8Array,\n bitsPerStatus: BitsPerStatus,\n aggregationUri?: string\n ): StatusList {\n try {\n const decompressed = inflate(compressed)\n const statusList = StatusList.decodeStatusListFromByteArray(decompressed, bitsPerStatus)\n return new StatusList(statusList, bitsPerStatus, aggregationUri)\n } catch (err: unknown) {\n throw new Error(`Decompression failed: ${err}`)\n }\n }\n\n /** Encode the status list into a byte array. */\n public encodeStatusListIntoByteArray(): Uint8Array {\n const numBits = this.bitsPerStatus\n const numBytes = Math.ceil((this.totalStatuses * numBits) / 8)\n const byteArray = new Uint8Array(numBytes)\n let byteIndex = 0\n let bitIndex = 0\n let currentByte = ''\n for (let i = 0; i < this.totalStatuses; i++) {\n const status = this._statusList[i]\n currentByte = status.toString(2).padStart(numBits, '0') + currentByte\n bitIndex += numBits\n\n if (bitIndex >= 8 || i === this.totalStatuses - 1) {\n if (i === this.totalStatuses - 1 && bitIndex % 8 !== 0) {\n currentByte = currentByte.padStart(8, '0')\n }\n byteArray[byteIndex] = Number.parseInt(currentByte, 2)\n currentByte = ''\n bitIndex = 0\n byteIndex++\n }\n }\n\n return byteArray\n }\n\n /** Decode the byte array into a status list. */\n private static decodeStatusListFromByteArray(byteArray: Uint8Array, bitsPerStatus: BitsPerStatus): StatusType[] {\n const numBits = bitsPerStatus\n const totalStatuses = (byteArray.length * 8) / numBits\n const statusList = new Array<number>(totalStatuses)\n let bitIndex = 0\n for (let i = 0; i < totalStatuses; i++) {\n const byte = byteArray[Math.floor((i * numBits) / 8)]\n let byteString = byte.toString(2)\n if (byteString.length < 8) {\n byteString = '0'.repeat(8 - byteString.length) + byteString\n }\n const status = byteString.slice(bitIndex, bitIndex + numBits)\n const group = Math.floor(i / (8 / numBits))\n const indexInGroup = i % (8 / numBits)\n const position = group * (8 / numBits) + (8 / numBits + -1 - indexInGroup)\n statusList[position] = Number.parseInt(status, 2)\n bitIndex = (bitIndex + numBits) % 8\n }\n return statusList\n }\n}\n","import { CborStructure, TypedMap, typedMap, zUint8Array } from '@owf/cose'\nimport { z } from 'zod'\nimport { StatusList } from '../status-list'\nimport type { BitsPerStatus } from '../types'\n\nexport const statusListCborEncodedSchema = typedMap([\n ['bits', z.union([z.literal(1), z.literal(2), z.literal(4), z.literal(8)])],\n ['lst', zUint8Array],\n ['aggregation_uri', z.string().optional()],\n])\n\nexport const statusListCborDecodedSchema = z.instanceof(StatusList)\n\nexport type StatusListCborEncodedStructure = z.infer<typeof statusListCborEncodedSchema>\nexport type StatusListCborDecodedStructure = z.infer<typeof statusListCborDecodedSchema>\n\nexport type CreateStatusListCborOptions = {\n bits: BitsPerStatus\n list: Uint8Array | number[]\n aggregationUri?: string\n}\n\nexport type StatusListCborWithStatusListOptions = {\n statusList: StatusList\n}\n\nexport class StatusListCbor extends CborStructure<StatusListCborEncodedStructure, StatusListCborDecodedStructure> {\n public statusList = this.structure\n\n public static override get encodingSchema() {\n return z.codec(statusListCborEncodedSchema, statusListCborDecodedSchema, {\n encode: (statusList) => {\n return new TypedMap([\n ['bits', statusList.getBitsPerStatus()],\n ['lst', statusList.compressStatusListToBytes()],\n ['aggregation_uri', statusList.aggregationUri],\n ]) satisfies StatusListCborEncodedStructure\n },\n decode: (input) => {\n return StatusList.decompressStatusListFromBytes(\n input.get('lst'),\n input.get('bits'),\n input.get('aggregation_uri')\n )\n },\n })\n }\n\n public static create(options: CreateStatusListCborOptions | StatusListCborWithStatusListOptions) {\n const statusList =\n 'statusList' in options\n ? options.statusList\n : options.list instanceof Uint8Array\n ? StatusList.decompressStatusListFromBytes(options.list, options.bits, options.aggregationUri)\n : new StatusList(options.list, options.bits, options.aggregationUri)\n\n return new StatusListCbor(statusList)\n }\n}\n","// ==================== Common Types & Constants ====================\n\n/**\n * Status Type values as defined in the spec.\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-7\n */\nexport enum StatusType {\n /** The status of the Referenced Token is valid, correct or legal. */\n Valid = 0x00,\n /** The status of the Referenced Token is revoked, annulled, taken back, recalled or cancelled. */\n Invalid = 0x01,\n /** The status of the Referenced Token is temporarily invalid, hanging, debarred from privilege. */\n Suspended = 0x02,\n /** Application-specific status (0x03). */\n ApplicationSpecific3 = 0x03,\n /** Application-specific status range start (0x0C). */\n ApplicationSpecificRangeStart = 0x0c,\n /** Application-specific status range end (0x0F). */\n ApplicationSpecificRangeEnd = 0x0f,\n}\n\n/**\n * Media types for Status List Tokens\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.7\n */\nexport const MediaTypes = {\n /** Media type for JWT-based Status List Token */\n StatusListJwt: 'application/statuslist+jwt',\n /** Media type for CWT-based Status List Token */\n StatusListCwt: 'application/statuslist+cwt',\n} as const\n\n/**\n * BitsPerStatus type.\n */\nexport type BitsPerStatus = 1 | 2 | 4 | 8\n\n/**\n * Reference to a status list entry.\n */\nexport interface StatusListEntry {\n idx: number\n uri: string\n}\n","import { CborStructure, RegisteredCwtClaimKey, TypedMap, typedMap } from '@owf/cose'\nimport z from 'zod'\nimport type { StatusList } from '../status-list'\nimport { StatusListCbor, type StatusListCborEncodedStructure } from './status-list-cbor'\n\nexport enum StatusListCwtClaimKey {\n TimeToLive = 65534,\n StatusList = 65533,\n}\n\nconst statusListCwtPayloadSchema = typedMap(\n [\n [RegisteredCwtClaimKey.Subject, z.string()],\n [RegisteredCwtClaimKey.IssuedAt, z.number()],\n [RegisteredCwtClaimKey.ExpirationTime, z.number().exactOptional()],\n [StatusListCwtClaimKey.TimeToLive, z.number().exactOptional()],\n [StatusListCwtClaimKey.StatusList, z.instanceof(StatusListCbor)],\n ],\n { allowAdditionalKeys: true }\n)\n\nexport type StatusListCwtPayloadEncodedStructure = z.infer<typeof statusListCwtPayloadSchema>\nexport type StatusListCwtPayloadDecodedStructure = z.infer<typeof statusListCwtPayloadSchema>\n\nexport type CreateStatusListCwtPayloadOptions = {\n subject: string\n statusList: StatusListCbor | StatusList\n issuedAt?: Date\n expirationTime?: Date\n timeToLive?: number\n additionalClaims?: Map<number | string, unknown>\n}\n\nexport class StatusListCwtPayload extends CborStructure<\n StatusListCwtPayloadEncodedStructure,\n StatusListCwtPayloadDecodedStructure\n> {\n public static override get encodingSchema() {\n return z.codec(statusListCwtPayloadSchema.in, statusListCwtPayloadSchema.out, {\n decode: (input) => {\n const map: StatusListCwtPayloadDecodedStructure = TypedMap.fromMap(input)\n\n map.set(\n StatusListCwtClaimKey.StatusList,\n StatusListCbor.fromEncodedStructure(\n input.get(StatusListCwtClaimKey.StatusList) as StatusListCborEncodedStructure\n )\n )\n\n return map\n },\n encode: (output) => {\n const map = output.toMap() as Map<unknown, unknown>\n map.set(StatusListCwtClaimKey.StatusList, output.get(StatusListCwtClaimKey.StatusList).encodedStructure)\n return map\n },\n })\n }\n\n public static create(options: CreateStatusListCwtPayloadOptions) {\n const map = new TypedMap([\n [RegisteredCwtClaimKey.Subject, options.subject],\n [RegisteredCwtClaimKey.IssuedAt, Math.floor((options.issuedAt?.getTime() ?? Date.now()) / 1000)],\n [\n StatusListCwtClaimKey.StatusList,\n options.statusList instanceof StatusListCbor\n ? options.statusList\n : StatusListCbor.create({ statusList: options.statusList }),\n ],\n ...(options.additionalClaims ?? new Map()).entries(),\n ]) satisfies StatusListCwtPayloadEncodedStructure\n\n if (options.expirationTime) {\n map.set(RegisteredCwtClaimKey.ExpirationTime, Math.floor(options.expirationTime.getTime() / 1000))\n }\n\n if (options.timeToLive) {\n map.set(StatusListCwtClaimKey.TimeToLive, options.timeToLive)\n }\n\n return new StatusListCwtPayload(statusListCwtPayloadSchema.parse(map.toMap()))\n }\n\n public get subject() {\n return this.structure.get(RegisteredCwtClaimKey.Subject)\n }\n\n public get issuedAt() {\n return new Date(this.structure.get(RegisteredCwtClaimKey.IssuedAt) * 1000)\n }\n\n public get expirationTime() {\n return this.structure.has(RegisteredCwtClaimKey.ExpirationTime)\n ? // biome-ignore lint/style/noNonNullAssertion: checked with `has` in the line above\n new Date(this.structure.get(RegisteredCwtClaimKey.ExpirationTime)! * 1000)\n : undefined\n }\n\n public get timeToLive() {\n return this.structure.get(StatusListCwtClaimKey.TimeToLive)\n }\n\n public get statusList() {\n return this.structure.get(StatusListCwtClaimKey.StatusList).statusList\n }\n\n public getCustomClaim<ClaimType = unknown>(key: number) {\n return this.structure.get(key) as ClaimType | unknown\n }\n\n public setStatusList(statusList: StatusList | StatusListCbor) {\n this.structure.set(\n StatusListCwtClaimKey.StatusList,\n statusList instanceof StatusListCbor ? statusList : StatusListCbor.create({ statusList })\n )\n }\n}\n","import {\n type CoseKey,\n Cwt,\n type Mac0Context,\n type ProtectedHeaderOptions,\n ProtectedHeaders,\n RegisteredCwtClaimKey,\n type Sign1Context,\n type SignatureAlgorithm,\n type UnprotectedHeaderOptions,\n UnprotectedHeaders,\n} from '@owf/cose'\nimport { StatusList } from '../status-list'\nimport { SLException } from '../status-list-exception'\nimport { type BitsPerStatus, MediaTypes, StatusType } from '../types'\nimport { StatusListCbor } from './status-list-cbor'\nimport { type CreateStatusListCwtPayloadOptions, StatusListCwtPayload } from './status-list-cwt-payload'\n\nexport type StatusListCwtOptions = {\n payload: StatusListCwtPayload | CreateStatusListCwtPayloadOptions\n protectedHeaders?: ProtectedHeaders | ProtectedHeaderOptions['protectedHeaders']\n unprotectedHeaders?: UnprotectedHeaders | UnprotectedHeaderOptions['unprotectedHeaders']\n signatureOrTag?: Uint8Array\n}\n\nexport enum StatusListCwtHeaderKey {\n Typ = 16,\n}\n\nexport class StatusListCwt {\n public payload: StatusListCwtPayload\n public protectedHeaders?: ProtectedHeaders\n public unprotectedHeaders?: UnprotectedHeaders\n private signatureOrTag?: Uint8Array\n\n public constructor(options: StatusListCwtOptions) {\n this.payload =\n options.payload instanceof StatusListCwtPayload ? options.payload : StatusListCwtPayload.create(options.payload)\n this.protectedHeaders =\n options.protectedHeaders instanceof ProtectedHeaders\n ? options.protectedHeaders\n : ProtectedHeaders.create({ protectedHeaders: options.protectedHeaders })\n this.unprotectedHeaders =\n options.unprotectedHeaders instanceof UnprotectedHeaders\n ? options.unprotectedHeaders\n : UnprotectedHeaders.create({ unprotectedHeaders: options.unprotectedHeaders })\n\n this.signatureOrTag = options.signatureOrTag\n\n if (this.protectedHeaders.headers.get(StatusListCwtHeaderKey.Typ) === undefined) {\n this.protectedHeaders.headers.set(StatusListCwtHeaderKey.Typ, MediaTypes.StatusListCwt)\n }\n }\n\n public setStatusList(statusList: StatusList | StatusListCbor) {\n this.payload.setStatusList(statusList)\n }\n\n public updateStatusList(index: number, value: number) {\n this.payload.statusList.setStatus(index, value)\n }\n\n /**\n *\n * Create a minimal status list cwt. If you want to configure more options, like additional claims, use the constructor method\n *\n */\n public static createFromStatusListAndSubject(\n statusList:\n | StatusList\n | StatusListCbor\n | { statusList: number[]; bitsPerStatus: BitsPerStatus; aggregationUri?: string },\n subject: string\n ) {\n const cborStatusList =\n statusList instanceof StatusListCbor\n ? statusList\n : statusList instanceof StatusList\n ? StatusListCbor.create({ statusList })\n : StatusListCbor.create({\n bits: statusList.bitsPerStatus,\n list: statusList.statusList,\n aggregationUri: statusList.aggregationUri,\n })\n\n return new StatusListCwt({ payload: StatusListCwtPayload.create({ statusList: cborStatusList, subject }) })\n }\n\n public static fromToken(token: Uint8Array) {\n const cwt = Cwt.fromToken(token)\n\n if (!cwt.payload) {\n throw new SLException('Cwt does not contain payload, detached payload is not supported for status list CWT')\n }\n const payload = StatusListCwtPayload.decode(cwt.payload)\n\n return new StatusListCwt({\n payload,\n protectedHeaders: cwt.protectedHeaders,\n unprotectedHeaders: cwt.unprotectedHeaders,\n signatureOrTag: cwt.signatureOrTag,\n })\n }\n\n public async signAndEncode(\n options: {\n signingKey: CoseKey\n algorithm?: SignatureAlgorithm\n },\n ctx: Pick<Sign1Context, 'sign'>\n ) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n })\n return (await cwt.asSign1.sign(options, ctx)).encode()\n }\n\n public async authenticateAndEncode(options: { key: CoseKey }, ctx: Pick<Mac0Context, 'authenticate'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n })\n return (await cwt.asMac0.authenticate(options, ctx)).encode()\n }\n\n /**\n * @todo add check for `ttl` claim\n */\n public verifyStatus({\n idx,\n uri,\n checkFreshness = true,\n now = new Date(),\n }: {\n idx: number\n uri: string\n checkFreshness?: boolean\n now?: Date\n }) {\n if (this.payload.expirationTime && this.payload.expirationTime < now) {\n throw new SLException(\n `The expiration claim (${RegisteredCwtClaimKey.ExpirationTime}) '${this.payload.expirationTime}' is in the past (compared to '${now}'), and therefore not valid`\n )\n }\n if (this.payload.subject !== uri) {\n throw new SLException(\n `The subject claim (${RegisteredCwtClaimKey.Subject}) '${this.payload.subject}' must be equal to the uri '${uri}'`\n )\n }\n if (checkFreshness && this.payload.issuedAt > now) {\n throw new SLException(\n `The issued at claim (${RegisteredCwtClaimKey.IssuedAt}) '${this.payload.issuedAt}' is in the future (compared to '${now}'), and therefore not valid`\n )\n }\n if (this.payload.statusList.getStatus(idx) !== StatusType.Valid) {\n throw new SLException(\n `Status for id '${idx}' is not Valid (${StatusType.Valid}), but is instead '${this.payload.statusList.getStatus(idx)}'`\n )\n }\n }\n\n public async verifySignature({ key }: { key: CoseKey }, ctx: Pick<Sign1Context, 'verify'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n signature: this.signatureOrTag,\n })\n\n return await cwt.verifySignature({ key }, ctx)\n }\n\n public async verifyAuthenticationCode({ key }: { key: CoseKey }, ctx: Pick<Mac0Context, 'verify'>) {\n const cwt = new Cwt({\n protectedHeaders: this.protectedHeaders,\n unprotectedHeaders: this.unprotectedHeaders,\n payload: this.payload.encode(),\n tag: this.signatureOrTag,\n })\n\n return await cwt.verifyAuthenticationCode({ key }, ctx)\n }\n}\n","import { CborStructure, TypedMap, typedMap, zUint8Array } from '@owf/cose'\nimport { z } from 'zod'\n\n/**\n * StatusListInfo carries a reference to an IETF Token Status List\n * (draft-ietf-oauth-status-list) entry from inside the MSO's Status structure.\n *\n * Defined in ISO/IEC 18013-5 second edition (CD), 12.3.6.\n */\n// NOTE: idx is `uint` in the spec (unbounded CBOR uint). We constrain to JS\n// safe-integer range here, which is more than enough for real-world status\n// list sizes (Number.MAX_SAFE_INTEGER is ~9 × 10^15).\nconst statusListInfoSchema = typedMap([\n ['uri', z.string()],\n ['idx', z.number().int().nonnegative()],\n ['certificate', zUint8Array.exactOptional()],\n])\n\nexport type StatusListInfoDecodedStructure = z.output<typeof statusListInfoSchema>\nexport type StatusListInfoEncodedStructure = z.input<typeof statusListInfoSchema>\n\nexport type StatusListInfoOptions = {\n uri: string\n idx: number\n certificate?: Uint8Array\n}\n\nexport class StatusListInfo extends CborStructure<StatusListInfoEncodedStructure, StatusListInfoDecodedStructure> {\n public static override get encodingSchema() {\n return statusListInfoSchema\n }\n\n public get uri() {\n return this.structure.get('uri')\n }\n\n public get idx() {\n return this.structure.get('idx')\n }\n\n public get certificate() {\n return this.structure.get('certificate')\n }\n\n public static create(options: StatusListInfoOptions): StatusListInfo {\n const map: StatusListInfoDecodedStructure = new TypedMap([\n ['uri', options.uri],\n ['idx', options.idx],\n ])\n if (options.certificate) {\n map.set('certificate', options.certificate)\n }\n return StatusListInfo.fromDecodedStructure(map)\n }\n}\n","import { SLException } from './status-list-exception'\nimport { MediaTypes } from './types'\n\nexport const fetchStatusList = async ({\n uri,\n customFetcher = fetch,\n acceptedFormats = ['jwt', 'cwt'],\n}: {\n uri: string\n /**\n *\n * If none is supplied either can be returned\n *\n */\n acceptedFormats?: Array<'cwt' | 'jwt'>\n customFetcher?: typeof fetch\n}): Promise<string | Uint8Array> => {\n try {\n if (acceptedFormats.length === 0) {\n throw new SLException(`At least one accepted format (cwt, jwt) needs to be provided`)\n }\n\n const acceptHeaders = acceptedFormats.map((format) =>\n format === 'jwt' ? MediaTypes.StatusListJwt : MediaTypes.StatusListCwt\n )\n\n const response = await customFetcher(uri, {\n headers: {\n Accept: acceptHeaders.join(','),\n },\n })\n\n if (response.status > 399 || response.status <= 199) {\n throw new Error(`Could not fetch status list, response status '${response.status}'`)\n }\n\n const contentType = response.headers.get('Content-type')\n if (contentType === MediaTypes.StatusListJwt) {\n return await response.text()\n } else if (contentType === MediaTypes.StatusListCwt) {\n return await (await response.blob()).bytes()\n }\n\n throw new SLException('Content type was either not provided in the response or invalid.')\n } catch (e) {\n throw new SLException(`Could not fetch either a JWT or CWT as status list. ${(e as Error).message}`)\n }\n}\n","import type { JwtPayload } from '@owf/identity-common'\nimport type { BitsPerStatus, StatusListEntry } from './types'\n\n// ==================== JWT Types & Constants ====================\n\n/**\n * JWT type header value for Status List Token\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-5.1\n */\nexport const JWT_STATUS_LIST_TYPE = 'statuslist+jwt'\n\n/**\n * JWT claim names for Status List\n * @see https://www.ietf.org/archive/id/draft-ietf-oauth-status-list-16.html#section-14.1\n */\nexport const JWTClaimNames = {\n STATUS: 'status',\n STATUS_LIST: 'status_list',\n TTL: 'ttl',\n IDX: 'idx',\n URI: 'uri',\n BITS: 'bits',\n LST: 'lst',\n AGGREGATION_URI: 'aggregation_uri',\n} as const\n\n/**\n * Payload for a JWT with a status reference.\n */\nexport interface JWTwithStatusListPayload extends JwtPayload {\n status: {\n status_list: StatusListEntry\n }\n}\n\n/**\n * Payload for a Status List JWT.\n */\nexport interface StatusListJWTPayload extends JwtPayload {\n ttl?: number\n status_list: {\n bits: BitsPerStatus\n lst: string\n }\n}\n\n/**\n * Header parameters for a JWT Status List Token.\n */\nexport type StatusListJWTHeaderParameters = {\n alg: string\n typ: typeof JWT_STATUS_LIST_TYPE\n [key: string]: unknown\n}\n","import type { JwtPayload } from '@owf/identity-common'\nimport { base64url, bytesToString } from '@owf/identity-common'\nimport type { JWTwithStatusListPayload, StatusListJWTHeaderParameters, StatusListJWTPayload } from './jwt-types'\nimport { JWT_STATUS_LIST_TYPE } from './jwt-types'\nimport { StatusList } from './status-list'\nimport { SLException } from './status-list-exception'\nimport { type StatusListEntry, StatusType } from './types'\n\n/**\n * Decode a JWT and return the payload.\n * @param jwt JWT token in compact JWS serialization.\n */\nfunction decodeJwtPayload<T>(jwt: string): T {\n const parts = jwt.split('.')\n return JSON.parse(bytesToString(base64url.decode(parts[1])))\n}\n\n/**\n * Adds the status list to the payload and header of a JWT.\n */\nexport function createHeaderAndPayload(list: StatusList, payload: JwtPayload, header: StatusListJWTHeaderParameters) {\n if (!payload.sub) {\n throw new SLException('sub field is required')\n }\n if (!payload.iat) {\n throw new SLException('iat field is required')\n }\n\n header.typ = JWT_STATUS_LIST_TYPE\n payload.status_list = {\n bits: list.getBitsPerStatus(),\n lst: base64url.encode(list.compressStatusListToBytes()),\n }\n return { header, payload }\n}\n\n/**\n * Get the status list from a JWT, but do not verify the signature.\n */\nexport function getListFromStatusListJWT(jwt: string): StatusList {\n const payload = decodeJwtPayload<StatusListJWTPayload>(jwt)\n const statusList = payload.status_list\n const compressed = base64url.decode(statusList.lst)\n return StatusList.decompressStatusListFromBytes(compressed, statusList.bits)\n}\n\n/**\n * Get the status list entry from a JWT, but do not verify the signature.\n */\nexport function getStatusListFromJWT(jwt: string): StatusListEntry {\n const payload = decodeJwtPayload<JWTwithStatusListPayload>(jwt)\n return payload.status.status_list\n}\n\n/**\n * Verify the status of an `idx` in a `token`\n *\n * @todo properly validate the JWT with zod + signature\n */\nexport function verifyStatus({\n uri,\n idx,\n token,\n checkFreshness = true,\n now = new Date(),\n}: {\n token: string\n idx: number\n uri: string\n checkFreshness?: boolean\n now?: Date\n}) {\n const payload = decodeJwtPayload<StatusListJWTPayload>(token)\n const compressed = base64url.decode(payload.status_list.lst)\n const statusList = StatusList.decompressStatusListFromBytes(compressed, payload.status_list.bits)\n if (payload.subject !== uri) {\n throw new SLException(`The subject claim '${payload.subject}' must be equal to the uri '${uri}'`)\n }\n if (checkFreshness && payload.iat && payload.iat > Math.floor(now.getTime() / 1000)) {\n throw new SLException(\n `The issued at claim '${payload.issuedAt}' is in the future (compared to '${now}'), and therefore not valid`\n )\n }\n if (payload.exp && payload.exp < Math.floor(now.getTime() / 1000)) {\n throw new SLException(\n `The expiry claim '${payload.exp}' is in the past (compared to '${now}'), and therefore not valid`\n )\n }\n if (statusList.getStatus(idx) !== StatusType.Valid) {\n throw new SLException(\n `Status for id '${idx}' is not Valid (${StatusType.Valid}), but is instead '${statusList.getStatus(idx)}'`\n )\n }\n return true\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,cAAb,MAAa,oBAAoB,kBAAkB;CACjD,YAAY,SAAiB,SAAmB;EAC9C,MAAM,SAAS,OAAO;EACtB,OAAO,eAAe,MAAM,YAAY,SAAS;EACjD,KAAK,OAAO;CACd;AACF;;;;;;ACJA,IAAa,aAAb,MAAa,WAAW;CAMtB,YAAY,YAAsB,eAA8B,gBAAyB;EACvF,IAAI,CAAC;GAAC;GAAG;GAAG;GAAG;EAAC,CAAC,CAAC,SAAS,aAAa,GACtC,MAAM,IAAI,YAAY,qCAAqC;EAE7D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KACrC,IAAI,WAAW,KAAK,KAAK,eACvB,MAAM,IAAI,YAAY,sCAAsC,EAAE,cA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M,IAAI,YACR,kBAAkB,IAAI,sCAAwD,WAAW,UAAU,GAAG,EAAE,EAC1G;CAEF,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owf/token-status-list",
|
|
3
|
-
"version": "0.3.2-alpha-
|
|
3
|
+
"version": "0.3.2-alpha-20260713153517",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"cbor-x": "^1.6.4",
|
|
31
|
-
"pako": "^3.0.
|
|
31
|
+
"pako": "^3.0.1",
|
|
32
32
|
"zod": "^4.4.3",
|
|
33
|
-
"@owf/cose": "0.3.2-alpha-
|
|
34
|
-
"@owf/identity-common": "0.3.2-alpha-
|
|
33
|
+
"@owf/cose": "0.3.2-alpha-20260713153517",
|
|
34
|
+
"@owf/identity-common": "0.3.2-alpha-20260713153517"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@noble/curves": "^2.2.0",
|