planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

42
node_modules/gotrue-js/tests/user.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
import { Buffer } from 'buffer';
import test from 'ava';
import sinon from 'sinon';
import User from '../src/user.js';
// mock window
global.window = { atob: (base64) => Buffer.from(base64, 'base64').toString('ascii') };
test('should parse token in ctor', (t) => {
//
// {
// "sub": "1234567890",
// "name": "John Doe",
// "iat": 1516239022,
// "exp": 1000
// }
//
const tokenResponse = {
access_token:
'header.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjEwMDB9.secret',
};
const user = new User({}, tokenResponse, '');
t.is(user.token.expires_at, 1000000);
});
test.serial('should not log token on error', (t) => {
const spy = sinon.spy(console, 'error');
const tokenResponse = {
access_token: 'header.invalid.secret',
};
// eslint-disable-next-line no-new
new User({}, tokenResponse, '');
t.assert(spy.calledOnce);
const [error] = spy.getCall(0).args;
t.true(error instanceof Error);
t.false(error.message.includes(tokenResponse.access_token));
});