Skip to content

Commit af26522

Browse files
authored
fix: generated token validated by akamai impl (#40)
1 parent b2d4c3f commit af26522

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

interop/__tests__/generate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const runInteropTests =
1010

1111
describe('CAT library', () => {
1212
testIf(
13-
false && runInteropTests, // Skip this test
13+
runInteropTests,
1414
'can generate a token that someone else can validate',
1515
async () => {
1616
const ctx = new Context();
@@ -23,12 +23,12 @@ describe('CAT library', () => {
2323
},
2424
expectCwtTag: true
2525
});
26-
const token = await generator.generate(
26+
const token = await generator.generateFromJson(
2727
{
2828
iss: 'eyevinn',
2929
sub: 'jonas',
3030
aud: 'coap://light.example.com',
31-
exp: 1444064944,
31+
exp: Math.floor(Date.now() / 1000) + 3600,
3232
nbf: 1443944944,
3333
iat: 1443944944,
3434
cti: '0b71'

src/cat.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ export class CommonAccessToken {
332332
key: key.k
333333
};
334334
if (!opts?.noCwtTag) {
335-
const plaintext = cbor.encode(this.payload);
335+
const encoder = new cbor.Encoder({ mapsAsObjects: false });
336+
const plaintext = encoder.encode(this.payload);
336337
const coseMessage = await cose.mac.create(
337338
headers,
338339
plaintext as unknown as string,

0 commit comments

Comments
 (0)