@owf/token-status-list 0.2.0 → 0.3.0-alpha-20260508181749
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 +0 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -363,40 +363,10 @@ function getStatusListFromJWT(jwt) {
|
|
|
363
363
|
return decodeJwtPayload(jwt).status.status_list;
|
|
364
364
|
}
|
|
365
365
|
//#endregion
|
|
366
|
-
Object.defineProperty(exports, "CoseKey", {
|
|
367
|
-
enumerable: true,
|
|
368
|
-
get: function() {
|
|
369
|
-
return _owf_cose.CoseKey;
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
366
|
exports.JWTClaimNames = JWTClaimNames;
|
|
373
367
|
exports.JWT_STATUS_LIST_TYPE = JWT_STATUS_LIST_TYPE;
|
|
374
|
-
Object.defineProperty(exports, "Mac0Context", {
|
|
375
|
-
enumerable: true,
|
|
376
|
-
get: function() {
|
|
377
|
-
return _owf_cose.Mac0Context;
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
Object.defineProperty(exports, "MacAlgorithm", {
|
|
381
|
-
enumerable: true,
|
|
382
|
-
get: function() {
|
|
383
|
-
return _owf_cose.MacAlgorithm;
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
368
|
exports.MediaTypes = MediaTypes;
|
|
387
369
|
exports.SLException = SLException;
|
|
388
|
-
Object.defineProperty(exports, "Sign1Context", {
|
|
389
|
-
enumerable: true,
|
|
390
|
-
get: function() {
|
|
391
|
-
return _owf_cose.Sign1Context;
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
Object.defineProperty(exports, "SignatureAlgorithm", {
|
|
395
|
-
enumerable: true,
|
|
396
|
-
get: function() {
|
|
397
|
-
return _owf_cose.SignatureAlgorithm;
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
370
|
exports.StatusList = StatusList;
|
|
401
371
|
exports.StatusListCbor = StatusListCbor;
|
|
402
372
|
exports.StatusListCwt = StatusListCwt;
|
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"],"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/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 } 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: number[]\n private bitsPerStatus: BitsPerStatus\n private 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): number {\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: 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): number[] {\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 const StatusTypes = {\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 APPLICATION_SPECIFIC_3: 0x03,\n /** Application-specific status range start (0x0C). */\n APPLICATION_SPECIFIC_RANGE_START: 0x0c,\n /** Application-specific status range end (0x0F). */\n APPLICATION_SPECIFIC_RANGE_END: 0x0f,\n} as const\n\nexport type StatusType = (typeof StatusTypes)[keyof typeof StatusTypes] | number\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 STATUS_LIST_JWT: 'application/statuslist+jwt',\n /** Media type for CWT-based Status List Token */\n STATUS_LIST_CWT: '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 [RegisteredCwtClaimKey.Subject, z.string()],\n [RegisteredCwtClaimKey.IssuedAt, z.number()],\n [RegisteredCwtClaimKey.ExpirationTime, z.number().optional()],\n [StatusListCwtClaimKey.TimeToLive, z.number().optional()],\n [StatusListCwtClaimKey.StatusList, z.instanceof(StatusListCbor)],\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}\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: StatusListCwtPayloadEncodedStructure = new TypedMap([\n [RegisteredCwtClaimKey.Subject, options.subject],\n [RegisteredCwtClaimKey.IssuedAt, Math.floor((options.issuedAt?.getTime() ?? Date.now()) / 1000)],\n [\n RegisteredCwtClaimKey.ExpirationTime,\n options.expirationTime ? Math.floor(options.expirationTime.getTime() / 1000) : undefined,\n ],\n [StatusListCwtClaimKey.TimeToLive, options.timeToLive],\n [\n StatusListCwtClaimKey.StatusList,\n options.statusList instanceof StatusListCbor\n ? options.statusList\n : StatusListCbor.create({ statusList: options.statusList }),\n ],\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 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 type Sign1Context,\n type SignatureAlgorithm,\n type UnprotectedHeaderOptions,\n UnprotectedHeaders,\n} from '@owf/cose'\nimport { StatusList } from '../status-list'\nimport { type BitsPerStatus, MediaTypes } 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}\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\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 if (this.protectedHeaders.headers.get(StatusListCwtHeaderKey.Typ) === undefined) {\n this.protectedHeaders.headers.set(StatusListCwtHeaderKey.Typ, MediaTypes.STATUS_LIST_CWT)\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, 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 const payload = StatusListCwtPayload.decode(cwt.payload)\n\n return new StatusListCwt({\n payload,\n protectedHeaders: cwt.protectedHeaders,\n unprotectedHeaders: cwt.unprotectedHeaders,\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: Uint8Array }, ctx: Pick<Mac0Context, 'mac'>) {\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","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 { base64UrlToUint8Array, base64urlDecode, uint8ArrayToBase64Url } 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 } 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(base64urlDecode(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: uint8ArrayToBase64Url(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 = base64UrlToUint8Array(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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAa,cAAb,MAAa,oBAAoBA,qBAAAA,kBAAkB;CACjD,YAAY,SAAiB,SAAmB;AAC9C,QAAM,SAAS,QAAQ;AACvB,SAAO,eAAe,MAAM,YAAY,UAAU;AAClD,OAAK,OAAO;;;;;;;;ACFhB,IAAa,aAAb,MAAa,WAAW;CAMtB,YAAY,YAAsB,eAA8B,gBAAyB;AACvF,MAAI,CAAC;GAAC;GAAG;GAAG;GAAG;GAAE,CAAC,SAAS,cAAc,CACvC,OAAM,IAAI,YAAY,sCAAsC;AAE9D,OAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,KAAI,WAAW,KAAK,KAAK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B,SAAgB,yBAAyB,KAAyB;CAEhE,MAAM,aADU,iBAAuC,IAAI,CAChC;CAC3B,MAAM,cAAA,GAAA,qBAAA,uBAAmC,WAAW,IAAI;AACxD,QAAO,WAAW,8BAA8B,YAAY,WAAW,KAAK;;;;;AAM9E,SAAgB,qBAAqB,KAA8B;AAEjE,QADgB,iBAA2C,IAAI,CAChD,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["IdentityException","z","zUint8Array","CborStructure","TypedMap","RegisteredCwtClaimKey","z","CborStructure","TypedMap","ProtectedHeaders","UnprotectedHeaders","Cwt"],"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/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 } 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: number[]\n private bitsPerStatus: BitsPerStatus\n private 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): number {\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: 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): number[] {\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 const StatusTypes = {\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 APPLICATION_SPECIFIC_3: 0x03,\n /** Application-specific status range start (0x0C). */\n APPLICATION_SPECIFIC_RANGE_START: 0x0c,\n /** Application-specific status range end (0x0F). */\n APPLICATION_SPECIFIC_RANGE_END: 0x0f,\n} as const\n\nexport type StatusType = (typeof StatusTypes)[keyof typeof StatusTypes] | number\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 STATUS_LIST_JWT: 'application/statuslist+jwt',\n /** Media type for CWT-based Status List Token */\n STATUS_LIST_CWT: '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 [RegisteredCwtClaimKey.Subject, z.string()],\n [RegisteredCwtClaimKey.IssuedAt, z.number()],\n [RegisteredCwtClaimKey.ExpirationTime, z.number().optional()],\n [StatusListCwtClaimKey.TimeToLive, z.number().optional()],\n [StatusListCwtClaimKey.StatusList, z.instanceof(StatusListCbor)],\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}\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: StatusListCwtPayloadEncodedStructure = new TypedMap([\n [RegisteredCwtClaimKey.Subject, options.subject],\n [RegisteredCwtClaimKey.IssuedAt, Math.floor((options.issuedAt?.getTime() ?? Date.now()) / 1000)],\n [\n RegisteredCwtClaimKey.ExpirationTime,\n options.expirationTime ? Math.floor(options.expirationTime.getTime() / 1000) : undefined,\n ],\n [StatusListCwtClaimKey.TimeToLive, options.timeToLive],\n [\n StatusListCwtClaimKey.StatusList,\n options.statusList instanceof StatusListCbor\n ? options.statusList\n : StatusListCbor.create({ statusList: options.statusList }),\n ],\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 setStatusList(statusList: StatusList | StatusListCbor) {\n this.structure.set(\n StatusListCwtClaimKey.StatusList,\n statusList instanceof StatusListCbor ? statusList : StatusListCbor.create({ statusList })\n )\n }\n}\n","import type { Mac0Context } from '@owf/cose'\nimport {\n type CoseKey,\n Cwt,\n type ProtectedHeaderOptions,\n ProtectedHeaders,\n type Sign1Context,\n type SignatureAlgorithm,\n type UnprotectedHeaderOptions,\n UnprotectedHeaders,\n} from '@owf/cose'\nimport { StatusList } from '../status-list'\nimport { type BitsPerStatus, MediaTypes } 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}\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\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 if (this.protectedHeaders.headers.get(StatusListCwtHeaderKey.Typ) === undefined) {\n this.protectedHeaders.headers.set(StatusListCwtHeaderKey.Typ, MediaTypes.STATUS_LIST_CWT)\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, 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 const payload = StatusListCwtPayload.decode(cwt.payload)\n\n return new StatusListCwt({\n payload,\n protectedHeaders: cwt.protectedHeaders,\n unprotectedHeaders: cwt.unprotectedHeaders,\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: Uint8Array }, ctx: Pick<Mac0Context, 'mac'>) {\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","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 { base64UrlToUint8Array, base64urlDecode, uint8ArrayToBase64Url } 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 } 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(base64urlDecode(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: uint8ArrayToBase64Url(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 = base64UrlToUint8Array(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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAa,cAAb,MAAa,oBAAoBA,qBAAAA,kBAAkB;CACjD,YAAY,SAAiB,SAAmB;AAC9C,QAAM,SAAS,QAAQ;AACvB,SAAO,eAAe,MAAM,YAAY,UAAU;AAClD,OAAK,OAAO;;;;;;;;ACFhB,IAAa,aAAb,MAAa,WAAW;CAMtB,YAAY,YAAsB,eAA8B,gBAAyB;AACvF,MAAI,CAAC;GAAC;GAAG;GAAG;GAAG;GAAE,CAAC,SAAS,cAAc,CACvC,OAAM,IAAI,YAAY,sCAAsC;AAE9D,OAAK,IA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K,2BAA2B,CAAC;EAC7D;AACD,QAAO;EAAE;EAAQ;EAAS;;;;;AAM5B,SAAgB,yBAAyB,KAAyB;CAEhE,MAAM,aADU,iBAAuC,IAAI,CAChC;CAC3B,MAAM,cAAA,GAAA,qBAAA,uBAAmC,WAAW,IAAI;AACxD,QAAO,WAAW,8BAA8B,YAAY,WAAW,KAAK;;;;;AAM9E,SAAgB,qBAAqB,KAA8B;AAEjE,QADgB,iBAA2C,IAAI,CAChD,OAAO"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CborStructure, CoseKey,
|
|
1
|
+
import { CborStructure, CoseKey, Mac0Context, ProtectedHeaderOptions, ProtectedHeaders, RegisteredCwtClaimKey, Sign1Context, SignatureAlgorithm, TypedMap, UnprotectedHeaderOptions, UnprotectedHeaders } from "@owf/cose";
|
|
2
2
|
import z$1, { z } from "zod";
|
|
3
3
|
import { IdentityException, JwtPayload } from "@owf/identity-common";
|
|
4
4
|
|
|
@@ -177,12 +177,12 @@ declare class StatusListCwt {
|
|
|
177
177
|
}, subject: string): StatusListCwt;
|
|
178
178
|
static fromToken(token: Uint8Array): StatusListCwt;
|
|
179
179
|
signAndEncode(options: {
|
|
180
|
-
signingKey: CoseKey
|
|
181
|
-
algorithm?: SignatureAlgorithm
|
|
182
|
-
}, ctx: Pick<Sign1Context
|
|
180
|
+
signingKey: CoseKey;
|
|
181
|
+
algorithm?: SignatureAlgorithm;
|
|
182
|
+
}, ctx: Pick<Sign1Context, 'sign'>): Promise<Uint8Array<ArrayBufferLike>>;
|
|
183
183
|
authenticateAndEncode(options: {
|
|
184
184
|
key: Uint8Array;
|
|
185
|
-
}, ctx: Pick<Mac0Context
|
|
185
|
+
}, ctx: Pick<Mac0Context, 'mac'>): Promise<Uint8Array<ArrayBufferLike>>;
|
|
186
186
|
}
|
|
187
187
|
//#endregion
|
|
188
188
|
//#region src/jwt-types.d.ts
|
|
@@ -257,5 +257,5 @@ declare function getListFromStatusListJWT(jwt: string): StatusList;
|
|
|
257
257
|
*/
|
|
258
258
|
declare function getStatusListFromJWT(jwt: string): StatusListEntry;
|
|
259
259
|
//#endregion
|
|
260
|
-
export { type BitsPerStatus,
|
|
260
|
+
export { type BitsPerStatus, type CreateStatusListCborOptions, type CreateStatusListCwtPayloadOptions, JWTClaimNames, JWT_STATUS_LIST_TYPE, type JWTwithStatusListPayload, MediaTypes, SLException, StatusList, StatusListCbor, type StatusListCborWithStatusListOptions, StatusListCwt, StatusListCwtClaimKey, StatusListCwtHeaderKey, type StatusListCwtOptions, StatusListCwtPayload, type StatusListEntry, type StatusListJWTHeaderParameters, type StatusListJWTPayload, type StatusType, StatusTypes, createHeaderAndPayload, getListFromStatusListJWT, getStatusListFromJWT };
|
|
261
261
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CborStructure, CoseKey,
|
|
1
|
+
import { CborStructure, CoseKey, Mac0Context, ProtectedHeaderOptions, ProtectedHeaders, RegisteredCwtClaimKey, Sign1Context, SignatureAlgorithm, TypedMap, UnprotectedHeaderOptions, UnprotectedHeaders } from "@owf/cose";
|
|
2
2
|
import z$1, { z } from "zod";
|
|
3
3
|
import { IdentityException, JwtPayload } from "@owf/identity-common";
|
|
4
4
|
|
|
@@ -177,12 +177,12 @@ declare class StatusListCwt {
|
|
|
177
177
|
}, subject: string): StatusListCwt;
|
|
178
178
|
static fromToken(token: Uint8Array): StatusListCwt;
|
|
179
179
|
signAndEncode(options: {
|
|
180
|
-
signingKey: CoseKey
|
|
181
|
-
algorithm?: SignatureAlgorithm
|
|
182
|
-
}, ctx: Pick<Sign1Context
|
|
180
|
+
signingKey: CoseKey;
|
|
181
|
+
algorithm?: SignatureAlgorithm;
|
|
182
|
+
}, ctx: Pick<Sign1Context, 'sign'>): Promise<Uint8Array<ArrayBufferLike>>;
|
|
183
183
|
authenticateAndEncode(options: {
|
|
184
184
|
key: Uint8Array;
|
|
185
|
-
}, ctx: Pick<Mac0Context
|
|
185
|
+
}, ctx: Pick<Mac0Context, 'mac'>): Promise<Uint8Array<ArrayBufferLike>>;
|
|
186
186
|
}
|
|
187
187
|
//#endregion
|
|
188
188
|
//#region src/jwt-types.d.ts
|
|
@@ -257,5 +257,5 @@ declare function getListFromStatusListJWT(jwt: string): StatusList;
|
|
|
257
257
|
*/
|
|
258
258
|
declare function getStatusListFromJWT(jwt: string): StatusListEntry;
|
|
259
259
|
//#endregion
|
|
260
|
-
export { type BitsPerStatus,
|
|
260
|
+
export { type BitsPerStatus, type CreateStatusListCborOptions, type CreateStatusListCwtPayloadOptions, JWTClaimNames, JWT_STATUS_LIST_TYPE, type JWTwithStatusListPayload, MediaTypes, SLException, StatusList, StatusListCbor, type StatusListCborWithStatusListOptions, StatusListCwt, StatusListCwtClaimKey, StatusListCwtHeaderKey, type StatusListCwtOptions, StatusListCwtPayload, type StatusListEntry, type StatusListJWTHeaderParameters, type StatusListJWTPayload, type StatusType, StatusTypes, createHeaderAndPayload, getListFromStatusListJWT, getStatusListFromJWT };
|
|
261
261
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CborStructure,
|
|
1
|
+
import { CborStructure, Cwt, ProtectedHeaders, RegisteredCwtClaimKey, TypedMap, UnprotectedHeaders, typedMap, zUint8Array } from "@owf/cose";
|
|
2
2
|
import z$1, { z } from "zod";
|
|
3
3
|
import { deflate, inflate } from "pako";
|
|
4
4
|
import { IdentityException, base64UrlToUint8Array, base64urlDecode, uint8ArrayToBase64Url } from "@owf/identity-common";
|
|
@@ -339,6 +339,6 @@ function getStatusListFromJWT(jwt) {
|
|
|
339
339
|
return decodeJwtPayload(jwt).status.status_list;
|
|
340
340
|
}
|
|
341
341
|
//#endregion
|
|
342
|
-
export {
|
|
342
|
+
export { JWTClaimNames, JWT_STATUS_LIST_TYPE, MediaTypes, SLException, StatusList, StatusListCbor, StatusListCwt, StatusListCwtClaimKey, StatusListCwtHeaderKey, StatusListCwtPayload, StatusTypes, createHeaderAndPayload, getListFromStatusListJWT, getStatusListFromJWT };
|
|
343
343
|
|
|
344
344
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["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/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 } 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: number[]\n private bitsPerStatus: BitsPerStatus\n private 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): number {\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: 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): number[] {\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 const StatusTypes = {\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 APPLICATION_SPECIFIC_3: 0x03,\n /** Application-specific status range start (0x0C). */\n APPLICATION_SPECIFIC_RANGE_START: 0x0c,\n /** Application-specific status range end (0x0F). */\n APPLICATION_SPECIFIC_RANGE_END: 0x0f,\n} as const\n\nexport type StatusType = (typeof StatusTypes)[keyof typeof StatusTypes] | number\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 STATUS_LIST_JWT: 'application/statuslist+jwt',\n /** Media type for CWT-based Status List Token */\n STATUS_LIST_CWT: '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 [RegisteredCwtClaimKey.Subject, z.string()],\n [RegisteredCwtClaimKey.IssuedAt, z.number()],\n [RegisteredCwtClaimKey.ExpirationTime, z.number().optional()],\n [StatusListCwtClaimKey.TimeToLive, z.number().optional()],\n [StatusListCwtClaimKey.StatusList, z.instanceof(StatusListCbor)],\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}\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: StatusListCwtPayloadEncodedStructure = new TypedMap([\n [RegisteredCwtClaimKey.Subject, options.subject],\n [RegisteredCwtClaimKey.IssuedAt, Math.floor((options.issuedAt?.getTime() ?? Date.now()) / 1000)],\n [\n RegisteredCwtClaimKey.ExpirationTime,\n options.expirationTime ? Math.floor(options.expirationTime.getTime() / 1000) : undefined,\n ],\n [StatusListCwtClaimKey.TimeToLive, options.timeToLive],\n [\n StatusListCwtClaimKey.StatusList,\n options.statusList instanceof StatusListCbor\n ? options.statusList\n : StatusListCbor.create({ statusList: options.statusList }),\n ],\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 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 type Sign1Context,\n type SignatureAlgorithm,\n type UnprotectedHeaderOptions,\n UnprotectedHeaders,\n} from '@owf/cose'\nimport { StatusList } from '../status-list'\nimport { type BitsPerStatus, MediaTypes } 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}\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\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 if (this.protectedHeaders.headers.get(StatusListCwtHeaderKey.Typ) === undefined) {\n this.protectedHeaders.headers.set(StatusListCwtHeaderKey.Typ, MediaTypes.STATUS_LIST_CWT)\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, 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 const payload = StatusListCwtPayload.decode(cwt.payload)\n\n return new StatusListCwt({\n payload,\n protectedHeaders: cwt.protectedHeaders,\n unprotectedHeaders: cwt.unprotectedHeaders,\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: Uint8Array }, ctx: Pick<Mac0Context, 'mac'>) {\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","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 { base64UrlToUint8Array, base64urlDecode, uint8ArrayToBase64Url } 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 } 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(base64urlDecode(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: uint8ArrayToBase64Url(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 = base64UrlToUint8Array(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"],"mappings":";;;;;;;;AAKA,IAAa,cAAb,MAAa,oBAAoB,kBAAkB;CACjD,YAAY,SAAiB,SAAmB;AAC9C,QAAM,SAAS,QAAQ;AACvB,SAAO,eAAe,MAAM,YAAY,UAAU;AAClD,OAAK,OAAO;;;;;;;;ACFhB,IAAa,aAAb,MAAa,WAAW;CAMtB,YAAY,YAAsB,eAA8B,gBAAyB;AACvF,MAAI,CAAC;GAAC;GAAG;GAAG;GAAG;GAAE,CAAC,SAAS,cAAc,CACvC,OAAM,IAAI,YAAY,sCAAsC;AAE9D,OAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,KAAI,WAAW,KAAK,KAAK,cACvB,OAAM,IAAI,YAAY,sCAAsC,EAAE,cAAc,WAAW,KAAK;AAGhG,OAAK,cAAc;AACnB,OAAK,gBAAgB;AACrB,OAAK,gBAAgB,WAAW;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IAAI;GAClB,kBAAkB,KAAK;GACvB,oBAAoB,KAAK;GACzB,SAAS,KAAK,QAAQ,QAAQ;GAC/B,CAAC,CACgB,OAAO,aAAa,SAAS,IAAI,EAAE,QAAQ;;;;;;;;;ACzGjE,MAAa,uBAAuB;;;;;AAMpC,MAAa,gBAAgB;CAC3B,QAAQ;CACR,aAAa;CACb,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,iBAAiB;CAClB;;;;;;;ACZD,SAAS,iBAAoB,KAAgB;CAC3C,MAAM,QAAQ,IAAI,MAAM,IAAI;AAC5B,QAAO,KAAK,MAAM,gBAAgB,MAAM,GAAG,CAAC;;;;;AAM9C,SAAgB,uBAAuB,MAAkB,SAAqB,QAAuC;AACnH,KAAI,CAAC,QAAQ,IACX,OAAM,IAAI,YAAY,wBAAwB;AAEhD,KAAI,CAAC,QAAQ,IACX,OAAM,IAAI,YAAY,wBAAwB;AAGhD,QAAO,MAAM;AACb,SAAQ,cAAc;EACpB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,sBAAsB,KAAK,2BAA2B,CAAC;EAC7D;AACD,QAAO;EAAE;EAAQ;EAAS;;;;;AAM5B,SAAgB,yBAAyB,KAAyB;CAEhE,MAAM,aADU,iBAAuC,IAAI,CAChC;CAC3B,MAAM,aAAa,sBAAsB,WAAW,IAAI;AACxD,QAAO,WAAW,8BAA8B,YAAY,WAAW,KAAK;;;;;AAM9E,SAAgB,qBAAqB,KAA8B;AAEjE,QADgB,iBAA2C,IAAI,CAChD,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["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/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 } 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: number[]\n private bitsPerStatus: BitsPerStatus\n private 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): number {\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: 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): number[] {\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 const StatusTypes = {\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 APPLICATION_SPECIFIC_3: 0x03,\n /** Application-specific status range start (0x0C). */\n APPLICATION_SPECIFIC_RANGE_START: 0x0c,\n /** Application-specific status range end (0x0F). */\n APPLICATION_SPECIFIC_RANGE_END: 0x0f,\n} as const\n\nexport type StatusType = (typeof StatusTypes)[keyof typeof StatusTypes] | number\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 STATUS_LIST_JWT: 'application/statuslist+jwt',\n /** Media type for CWT-based Status List Token */\n STATUS_LIST_CWT: '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 [RegisteredCwtClaimKey.Subject, z.string()],\n [RegisteredCwtClaimKey.IssuedAt, z.number()],\n [RegisteredCwtClaimKey.ExpirationTime, z.number().optional()],\n [StatusListCwtClaimKey.TimeToLive, z.number().optional()],\n [StatusListCwtClaimKey.StatusList, z.instanceof(StatusListCbor)],\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}\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: StatusListCwtPayloadEncodedStructure = new TypedMap([\n [RegisteredCwtClaimKey.Subject, options.subject],\n [RegisteredCwtClaimKey.IssuedAt, Math.floor((options.issuedAt?.getTime() ?? Date.now()) / 1000)],\n [\n RegisteredCwtClaimKey.ExpirationTime,\n options.expirationTime ? Math.floor(options.expirationTime.getTime() / 1000) : undefined,\n ],\n [StatusListCwtClaimKey.TimeToLive, options.timeToLive],\n [\n StatusListCwtClaimKey.StatusList,\n options.statusList instanceof StatusListCbor\n ? options.statusList\n : StatusListCbor.create({ statusList: options.statusList }),\n ],\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 setStatusList(statusList: StatusList | StatusListCbor) {\n this.structure.set(\n StatusListCwtClaimKey.StatusList,\n statusList instanceof StatusListCbor ? statusList : StatusListCbor.create({ statusList })\n )\n }\n}\n","import type { Mac0Context } from '@owf/cose'\nimport {\n type CoseKey,\n Cwt,\n type ProtectedHeaderOptions,\n ProtectedHeaders,\n type Sign1Context,\n type SignatureAlgorithm,\n type UnprotectedHeaderOptions,\n UnprotectedHeaders,\n} from '@owf/cose'\nimport { StatusList } from '../status-list'\nimport { type BitsPerStatus, MediaTypes } 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}\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\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 if (this.protectedHeaders.headers.get(StatusListCwtHeaderKey.Typ) === undefined) {\n this.protectedHeaders.headers.set(StatusListCwtHeaderKey.Typ, MediaTypes.STATUS_LIST_CWT)\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, 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 const payload = StatusListCwtPayload.decode(cwt.payload)\n\n return new StatusListCwt({\n payload,\n protectedHeaders: cwt.protectedHeaders,\n unprotectedHeaders: cwt.unprotectedHeaders,\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: Uint8Array }, ctx: Pick<Mac0Context, 'mac'>) {\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","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 { base64UrlToUint8Array, base64urlDecode, uint8ArrayToBase64Url } 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 } 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(base64urlDecode(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: uint8ArrayToBase64Url(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 = base64UrlToUint8Array(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"],"mappings":";;;;;;;;AAKA,IAAa,cAAb,MAAa,oBAAoB,kBAAkB;CACjD,YAAY,SAAiB,SAAmB;AAC9C,QAAM,SAAS,QAAQ;AACvB,SAAO,eAAe,MAAM,YAAY,UAAU;AAClD,OAAK,OAAO;;;;;;;;ACFhB,IAAa,aAAb,MAAa,WAAW;CAMtB,YAAY,YAAsB,eAA8B,gBAAyB;AACvF,MAAI,CAAC;GAAC;GAAG;GAAG;GAAG;GAAE,CAAC,SAAS,cAAc,CACvC,OAAM,IAAI,YAAY,sCAAsC;AAE9D,OAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,KAAI,WAAW,KAAK,KAAK,cACvB,OAAM,IAAI,YAAY,sCAAsC,EAAE,cAAc,WAAW,KAAK;AAGhG,OAAK,cAAc;AACnB,OAAK,gBAAgB;AACrB,OAAK,gBAAgB,WAAW;AAChC,OAAK,iBAAiB;;;CAIxB,IAAI,aAAuB;AACzB,SAAO,KAAK;;;CAId,mBAAkC;AAChC,SAAO,KAAK;;;CAId,UAAU,OAAuB;AAC/B,MAAI,QAAQ,KAAK,SAAS,KAAK,cAC7B,OAAM,IAAI,MAAM,sBAAsB;AAExC,SAAO,KAAK,YAAY;;;CAI1B,UAAU,OAAe,OAAqB;AAC5C,MAAI,QAAQ,KAAK,SAAS,KAAK,cAC7B,OAAM,IAAI,MAAM,sBAAsB;AAExC,OAAK,YAAY,SAAS;;;CAI5B,4BAAwC;AAEtC,SAAO,QADW,KAAK,+BAA+B,EAC5B,EAAE,OAAO,GAAG,CAAC;;;CAIzC,OAAO,8BACL,YACA,eACA,gBACY;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AqB,QAAuC;AACnH,KAAI,CAAC,QAAQ,IACX,OAAM,IAAI,YAAY,wBAAwB;AAEhD,KAAI,CAAC,QAAQ,IACX,OAAM,IAAI,YAAY,wBAAwB;AAGhD,QAAO,MAAM;AACb,SAAQ,cAAc;EACpB,MAAM,KAAK,kBAAkB;EAC7B,KAAK,sBAAsB,KAAK,2BAA2B,CAAC;EAC7D;AACD,QAAO;EAAE;EAAQ;EAAS;;;;;AAM5B,SAAgB,yBAAyB,KAAyB;CAEhE,MAAM,aADU,iBAAuC,IAAI,CAChC;CAC3B,MAAM,aAAa,sBAAsB,WAAW,IAAI;AACxD,QAAO,WAAW,8BAA8B,YAAY,WAAW,KAAK;;;;;AAM9E,SAAgB,qBAAqB,KAA8B;AAEjE,QADgB,iBAA2C,IAAI,CAChD,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owf/token-status-list",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha-20260508181749",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"cbor-x": "^1.6.4",
|
|
31
31
|
"pako": "^2.1.0",
|
|
32
32
|
"zod": "^4.4.3",
|
|
33
|
-
"@owf/cose": "0.
|
|
34
|
-
"@owf/identity-common": "0.
|
|
33
|
+
"@owf/cose": "0.3.0-alpha-20260508181749",
|
|
34
|
+
"@owf/identity-common": "0.3.0-alpha-20260508181749"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/pako": "^2.0.4"
|