Skip to content

Commit 692a8bf

Browse files
authored
fix: handle bytearray (#30)
1 parent 95026f7 commit 692a8bf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/cat.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ export const labelsToClaim: { [key: number]: string } = {
7272
};
7373

7474
const claimTransform: { [key: string]: (value: string) => Buffer } = {
75-
cti: (value) => Buffer.from(value, 'hex'),
75+
cti: (value: unknown) =>
76+
value instanceof Uint8Array
77+
? Buffer.copyBytesFrom(value)
78+
: Buffer.from(value as string, 'hex'),
7679
cattpk: (value) => Buffer.from(value, 'hex')
7780
};
7881

@@ -237,8 +240,9 @@ function updateMapFromClaims(
237240
CommonAccessTokenIf.fromDictTags(dict[param] as any).payload
238241
);
239242
} else {
240-
const value = claimTransform[param]
241-
? claimTransform[param](dict[param] as string)
243+
const k = param.match(/\d+/) ? labelsToClaim[parseInt(param)] : param;
244+
const value = claimTransform[k]
245+
? claimTransform[k](dict[param] as string)
242246
: dict[param];
243247
map.set(key, value);
244248
}

0 commit comments

Comments
 (0)