Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/cat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@
};

const claimTransform: { [key: string]: (value: string) => Buffer } = {
cti: (value) => Buffer.from(value, 'hex'),
cti: (value: unknown) =>
value instanceof Uint8Array
? Buffer.copyBytesFrom(value)
: Buffer.from(value as string, 'hex'),
cattpk: (value) => Buffer.from(value, 'hex')
};

Expand Down Expand Up @@ -147,16 +150,16 @@
* Common Access Token Claims
*/
export type CommonAccessTokenClaims = {
[key: string]: string | number | Map<number | string, any>;

Check warning on line 153 in src/cat.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
};
export type CommonAccessTokenDict = {
[key: string]: string | number | { [key: string]: any };

Check warning on line 156 in src/cat.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
};
export type CommonAccessTokenValue =
| string
| number
| Buffer
| Map<number | string, any>;

Check warning on line 162 in src/cat.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* CWT Encryption Key
Expand Down Expand Up @@ -210,7 +213,7 @@
if (key === claimsToLabels['catu'] && !(dict[param] instanceof Map)) {
map.set(
key,
CommonAccessTokenUri.fromDictTags(dict[param] as any).payload

Check warning on line 216 in src/cat.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
);
} else if (
key === claimsToLabels['catr'] &&
Expand All @@ -218,7 +221,7 @@
) {
map.set(
key,
CommonAccessTokenRenewal.fromDictTags(dict[param] as any).payload

Check warning on line 224 in src/cat.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
);
} else if (
key === claimsToLabels['cath'] &&
Expand All @@ -237,8 +240,9 @@
CommonAccessTokenIf.fromDictTags(dict[param] as any).payload
);
} else {
const value = claimTransform[param]
? claimTransform[param](dict[param] as string)
const k = param.match(/\d+/) ? labelsToClaim[parseInt(param)] : param;
const value = claimTransform[k]
? claimTransform[k](dict[param] as string)
: dict[param];
map.set(key, value);
}
Expand Down
Loading