Skip to content

Commit

Permalink
Merge branch 'jul/default-export' into 'master'
Browse files Browse the repository at this point in the history
misc(import): remove default export from @tanker packages

See merge request TankerHQ/sdk-js!970
  • Loading branch information
JMounier committed Mar 21, 2023
2 parents ddada29 + 35b59bb commit 8839682
Show file tree
Hide file tree
Showing 90 changed files with 203 additions and 216 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ rules:
- error
- allowForLoopAfterthoughts: true
no-restricted-syntax: 0
no-restricted-exports:
- error
- restrictedNamedExports:
- then
restrictDefaultExports:
direct: true
named: true
defaultFrom: true
namedFrom: true
namespaceFrom: true
no-underscore-dangle:
- error
- allowAfterThis: true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"colorette": "2.0.19",
"core-js": "^3.27.1",
"core-js-pure": "^3.27.1",
"eslint": "8.31.0",
"eslint": "8.36.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-plugin-chai-expect": "3.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/client-browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { TankerOptions } from '@tanker/core';
import { Tanker as TankerCore, optionsWithDefaults } from '@tanker/core';
import Dexie from '@tanker/datastore-dexie-browser';
import { dexieBrowser } from '@tanker/datastore-dexie-browser';

const defaultOptions = {
dataStore: { adapter: Dexie },
dataStore: { adapter: dexieBrowser },
sdkType: 'client-browser',
};

Expand All @@ -15,4 +15,4 @@ class Tanker extends TankerCore {

export { errors, fromBase64, toBase64, prehashPassword, Padding } from '@tanker/core';
export { Tanker };
export default Tanker;
export default Tanker; // eslint-disable-line no-restricted-exports
6 changes: 3 additions & 3 deletions packages/client-node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { TankerOptions } from '@tanker/core';
import { Tanker as TankerCore, optionsWithDefaults } from '@tanker/core';
import PouchDB from '@tanker/datastore-pouchdb-node';
import { pouchDBNode } from '@tanker/datastore-pouchdb-node';

const defaultOptions = {
dataStore: { adapter: PouchDB },
dataStore: { adapter: pouchDBNode },
sdkType: 'client-node',
};

Expand All @@ -15,4 +15,4 @@ class Tanker extends TankerCore {

export { errors, fromBase64, toBase64, prehashPassword, Padding } from '@tanker/core';
export { Tanker };
export default Tanker;
export default Tanker; // eslint-disable-line no-restricted-exports
4 changes: 1 addition & 3 deletions packages/core/src/CloudStorage/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { utils, getClearSize, EncryptionV4, EncryptionV8, Padding } from '@tanke
import { InternalError } from '@tanker/errors';
import { MergerStream, ResizerStream, SlicerStream } from '@tanker/stream-base';
import type { Readable, Transform, Writable, IWritable } from '@tanker/stream-base';
import streamCloudStorage from '@tanker/stream-cloud-storage';
import { streamCloudStorage } from '@tanker/stream-cloud-storage';
import { getDataLength } from '@tanker/types';
import type { Data, ResourceMetadata } from '@tanker/types';

Expand Down Expand Up @@ -162,5 +162,3 @@ export class CloudStorageManager {
return new DownloadStream(streams, resourceMetadata);
}
}

export default CloudStorageManager;
12 changes: 5 additions & 7 deletions packages/core/src/DataProtection/DataProtector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import type { Data } from '@tanker/types';
import { _deserializePublicIdentity, _splitProvisionalAndPermanentPublicIdentities, assertTrustchainId, _serializeIdentity } from '../Identity';
import type { PublicIdentity, PublicProvisionalUser } from '../Identity';
import type { Client } from '../Network/Client';
import type LocalUser from '../LocalUser/LocalUser';
import type ResourceManager from '../Resources/Manager';
import type ProvisionalIdentityManager from '../ProvisionalIdentity/Manager';
import type GroupManager from '../Groups/Manager';
import type UserManager from '../Users/Manager';
import type { LocalUser } from '../LocalUser/LocalUser';
import type { ResourceManager } from '../Resources/Manager';
import type { ProvisionalIdentityManager } from '../ProvisionalIdentity/Manager';
import type { GroupManager } from '../Groups/Manager';
import type { UserManager } from '../Users/Manager';

import { getSimpleEncryptionWithFixedResourceId, getSimpleEncryption, makeResource } from './types';
import { makeKeyPublish, makeKeyPublishToProvisionalUser } from '../Resources/Serialize';
Expand Down Expand Up @@ -353,5 +353,3 @@ export class DataProtector {
return new EncryptionSession(this, getStatus, resource, encryptionOptions.paddingStep);
}
}

export default DataProtector;
2 changes: 1 addition & 1 deletion packages/core/src/DataProtection/options.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { b64string } from '@tanker/crypto';
import { tcrypto, utils, Padding, isPaddingStep } from '@tanker/crypto';
import { InternalError, InvalidArgument } from '@tanker/errors';
import globalThis from '@tanker/global-this';
import { globalThis } from '@tanker/global-this';
import { getConstructor, assertNotEmptyString, assertInteger } from '@tanker/types';
import type { Class, Data, ResourceMetadata } from '@tanker/types';

Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/Groups/GroupStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,3 @@ export class GroupStore {
}) as unknown as Array<GroupEntry>;
}
}

export default GroupStore;
8 changes: 4 additions & 4 deletions packages/core/src/Groups/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { InvalidArgument } from '@tanker/errors';
import { _deserializePublicIdentity, _splitProvisionalAndPermanentPublicIdentities, _serializeIdentity, assertTrustchainId } from '../Identity';
import { TaskCoalescer } from '../TaskCoalescer';
import type { PublicPermanentIdentity, PublicProvisionalIdentity } from '../Identity';
import type UserManager from '../Users/Manager';
import type LocalUser from '../LocalUser/LocalUser';
import type ProvisionalIdentityManager from '../ProvisionalIdentity/Manager';
import type { UserManager } from '../Users/Manager';
import type { LocalUser } from '../LocalUser/LocalUser';
import type { ProvisionalIdentityManager } from '../ProvisionalIdentity/Manager';

import { getGroupEntryFromBlock, makeUserGroupCreation, makeUserGroupAdditionV3, makeUserGroupRemoval } from './Serialize';
import type { Client } from '../Network/Client';
Expand Down Expand Up @@ -56,7 +56,7 @@ type GroupEncryptionKeyPairRecord = {
keys: tcrypto.SodiumKeyPair;
};

export default class GroupManager {
export class GroupManager {
_localUser: LocalUser;
_UserManager: UserManager;
_provisionalIdentityManager: ProvisionalIdentityManager;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Groups/ManagerHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type { Group, ExternalGroup, InternalGroup } from './types';
import { isInternalGroup } from './types';
import { verifyGroupAction } from './Verify';

import type ProvisionalIdentityManager from '../ProvisionalIdentity/Manager';
import type LocalUser from '../LocalUser/LocalUser';
import type { ProvisionalIdentityManager } from '../ProvisionalIdentity/Manager';
import type { LocalUser } from '../LocalUser/LocalUser';
import type { PrivateProvisionalKeys } from '../LocalUser/Manager';

export const MAX_GROUP_MEMBERS_PER_OPERATION = 1000;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Groups/__tests__/GroupStore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { random, ready as cryptoReady, tcrypto, utils } from '@tanker/crypto';
import { createUserSecretBinary } from '@tanker/identity';
import { expect } from '@tanker/test-utils';
import dataStoreConfig, { makePrefix, openDataStore } from '../../__tests__/TestDataStore';
import { dataStoreConfig, makePrefix, openDataStore } from '../../__tests__/TestDataStore';
import { Storage } from '../../Session/Storage';
import GroupStore from '../GroupStore';
import { GroupStore } from '../GroupStore';

describe('GroupStore', () => {
let dbName;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Groups/__tests__/ManagerHelper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import type { UserGroupCreationRecord, UserGroupEntry } from '../Serialize';
import type { ExternalGroup } from '../types';

import type { TestDeviceCreation, TestUserGroup } from '../../__tests__/TestGenerator';
import TestGenerator from '../../__tests__/TestGenerator';
import type ProvisionalIdentityManager from '../../ProvisionalIdentity/Manager';
import type LocalUser from '../../LocalUser/LocalUser';
import { TestGenerator } from '../../__tests__/TestGenerator';
import type { ProvisionalIdentityManager } from '../../ProvisionalIdentity/Manager';
import type { LocalUser } from '../../LocalUser/LocalUser';

function getExternalGroupFromUserGroupCreation(userGroupEntry: UserGroupEntry): ExternalGroup {
const userGroupCreation = userGroupEntry as UserGroupCreationRecord;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Groups/__tests__/Serialize.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ready as cryptoReady, tcrypto } from '@tanker/crypto';
import { expect } from '@tanker/test-utils';

import makeUint8Array from '../../__tests__/makeUint8Array';
import { makeUint8Array } from '../../__tests__/makeUint8Array';

import {
serializeUserGroupCreationV1,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Groups/__tests__/Verification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { UserGroupEntry } from '../Serialize';
import { verifyUserGroupCreation, verifyUserGroupAddition } from '../Verify';
import type { User } from '../../Users/types';

import TestGenerator from '../../__tests__/TestGenerator';
import { TestGenerator } from '../../__tests__/TestGenerator';
import { assertFailWithNature } from '../../__tests__/assertFailWithNature';

describe('BlockVerification', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/LocalUser/KeyStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type LocalData = {
userKeys: Record<string, tcrypto.SodiumKeyPair>;
};

export default class KeyStore {
export class KeyStore {
declare _ds: DataStore;
declare _safe: KeySafe;

Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/LocalUser/LocalUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,3 @@ export class LocalUser extends EventEmitter {
return localUserKeys;
};
}

export default LocalUser;
6 changes: 2 additions & 4 deletions packages/core/src/LocalUser/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
decryptVerificationKeyBytes,
} from './ghostDevice';
import type { IndexedProvisionalUserKeyPairs } from './KeySafe';
import type KeyStore from './KeyStore';
import LocalUser from './LocalUser';
import type { KeyStore } from './KeyStore';
import { LocalUser } from './LocalUser';
import {
formatVerificationRequest,
isPreverifiedVerificationRequest,
Expand Down Expand Up @@ -389,5 +389,3 @@ export class LocalUserManager extends EventEmitter {
return res;
};
}

export default LocalUserManager;
4 changes: 2 additions & 2 deletions packages/core/src/LocalUser/__tests__/KeyStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { createUserSecretBinary } from '@tanker/identity';
import { expect } from '@tanker/test-utils';
import type { DataStore } from '@tanker/datastore-base';

import dataStoreConfig, { makePrefix, openDataStore } from '../../__tests__/TestDataStore';
import { dataStoreConfig, makePrefix, openDataStore } from '../../__tests__/TestDataStore';
import { Storage } from '../../Session/Storage';

import KeyStore from '../KeyStore';
import { KeyStore } from '../KeyStore';

describe('KeyStore', () => {
let datastoresToClose: Array<DataStore>;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/LocalUser/__tests__/LocalUser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { createIdentity } from '@tanker/identity';
import { expect } from '@tanker/test-utils';

import type { TestUser, TestTrustchainCreation, TestDeviceCreation } from '../../__tests__/TestGenerator';
import TestGenerator from '../../__tests__/TestGenerator';
import { TestGenerator } from '../../__tests__/TestGenerator';

import LocalUser from '../LocalUser';
import { LocalUser } from '../LocalUser';
import { extractUserData } from '../UserData';
import type { UserData } from '../UserData';

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/LocalUser/__tests__/LocalUserVerify.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ready as cryptoReady } from '@tanker/crypto';
import { expect } from '@tanker/test-utils';

import TestGenerator from '../../__tests__/TestGenerator';
import makeUint8Array from '../../__tests__/makeUint8Array';
import { TestGenerator } from '../../__tests__/TestGenerator';
import { makeUint8Array } from '../../__tests__/makeUint8Array';
import { assertFailWithNature } from '../../__tests__/assertFailWithNature';

import { verifyTrustchainCreation } from '../Verify';
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/OidcNonce/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,3 @@ export class OidcNonceManager {
return payload.nonce;
};
}

export default OidcNonceManager;
2 changes: 0 additions & 2 deletions packages/core/src/OidcNonce/OidcStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,3 @@ export class OidcStore {
return new OidcStore(ds);
}
}

export default OidcStore;
4 changes: 2 additions & 2 deletions packages/core/src/OidcNonce/__tests__/OidcStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { b64string, ready as cryptoReady, tcrypto, utils } from '@tanker/crypto'
import { InternalError } from '@tanker/errors';
import { expect } from '@tanker/test-utils';

import dataStoreConfig, { makePrefix, openDataStore } from '../../__tests__/TestDataStore';
import { dataStoreConfig, makePrefix, openDataStore } from '../../__tests__/TestDataStore';
import { UnauthSessionStorage } from '../../UnauthSession/UnauthSessionStorage';

import OidcStore, { TABLE, idFromNonce } from '../OidcStore';
import { OidcStore, TABLE, idFromNonce } from '../OidcStore';

describe('OidcStore', () => {
let nonceStore: OidcStore;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/ProvisionalIdentity/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Client } from '../Network/Client';
import type { TankerProvisionalIdentityResponse } from '../Network/types';
import type { PrivateProvisionalKeys, LocalUserManager } from '../LocalUser/Manager';

import type KeyStore from '../LocalUser/KeyStore';
import type { KeyStore } from '../LocalUser/KeyStore';
import { formatProvisionalKeysRequest, formatVerificationRequest } from '../LocalUser/requests';
import type {
EmailVerification,
Expand All @@ -16,7 +16,7 @@ import type {
ProvisionalVerificationMethod,
} from '../LocalUser/types';
import { Status } from '../Session/status';
import type UserManager from '../Users/Manager';
import type { UserManager } from '../Users/Manager';

import { provisionalIdentityClaimFromBlock, makeProvisionalIdentityClaim } from './Serialize';
import { verifyProvisionalIdentityClaim } from './Verify';
Expand All @@ -39,7 +39,7 @@ const toTankerProvisionalKeys = (serverResult: TankerProvisionalIdentityResponse
},
});

export default class ProvisionalIdentityManager {
export class ProvisionalIdentityManager {
_client: Client;
_keyStore: KeyStore;
_localUserManager: LocalUserManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
unserializeProvisionalIdentityClaim,
} from '../Serialize';

import makeUint8Array from '../../__tests__/makeUint8Array';
import { makeUint8Array } from '../../__tests__/makeUint8Array';

// NOTE: If you ever have to change something here, change it in the Go code too!
// The test vectors should stay the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { User } from '../../Users/types';
import type { ClaimEntry } from '../Serialize';
import { verifyProvisionalIdentityClaim } from '../Verify';

import TestGenerator from '../../__tests__/TestGenerator';
import { TestGenerator } from '../../__tests__/TestGenerator';
import { assertFailWithNature } from '../../__tests__/assertFailWithNature';

describe('BlockVerification', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Resources/KeyDecryptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { Key } from '@tanker/crypto';
import { tcrypto } from '@tanker/crypto';
import { DecryptionFailed, InternalError } from '@tanker/errors';

import type GroupManager from '../Groups/Manager';
import type LocalUserManager from '../LocalUser/Manager';
import type ProvisionalIdentityManager from '../ProvisionalIdentity/Manager';
import type { GroupManager } from '../Groups/Manager';
import type { LocalUserManager } from '../LocalUser/Manager';
import type { ProvisionalIdentityManager } from '../ProvisionalIdentity/Manager';

import type { KeyPublishEntry } from './Serialize';
import { isKeyPublishToUser, isKeyPublishToUserGroup, isKeyPublishToProvisionalUser } from './Serialize';
Expand Down
10 changes: 4 additions & 6 deletions packages/core/src/Resources/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { KeyDecryptor } from './KeyDecryptor';
import { TaskCoalescer } from '../TaskCoalescer';

import type { Client } from '../Network/Client';
import type ResourceStore from './ResourceStore';
import type LocalUserManager from '../LocalUser/Manager';
import type GroupManager from '../Groups/Manager';
import type ProvisionalIdentityManager from '../ProvisionalIdentity/Manager';
import type { ResourceStore } from './ResourceStore';
import type { LocalUserManager } from '../LocalUser/Manager';
import type { GroupManager } from '../Groups/Manager';
import type { ProvisionalIdentityManager } from '../ProvisionalIdentity/Manager';

export type KeyResult = {
id: b64string;
Expand Down Expand Up @@ -71,5 +71,3 @@ export class ResourceManager {

saveResourceKey = (resourceId: Uint8Array, key: Uint8Array): Promise<void> => this._resourceStore.saveResourceKey(resourceId, key);
}

export default ResourceManager;
2 changes: 1 addition & 1 deletion packages/core/src/Resources/ResourceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { InternalError } from '@tanker/errors';

const TABLE = 'resource_keys';

export default class ResourceStore {
export class ResourceStore {
declare _ds: DataStore;
declare _userSecret: Uint8Array;

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Resources/__tests__/KeyDecryptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { expect } from '@tanker/test-utils';

import { KeyDecryptor } from '../KeyDecryptor';

import type GroupManager from '../../Groups/Manager';
import type LocalUserManager from '../../LocalUser/Manager';
import type ProvisionalIdentityManager from '../../ProvisionalIdentity/Manager';
import type { GroupManager } from '../../Groups/Manager';
import type { LocalUserManager } from '../../LocalUser/Manager';
import type { ProvisionalIdentityManager } from '../../ProvisionalIdentity/Manager';
import { NATURE } from '../../Blocks/Nature';
import type { Nature } from '../../Blocks/Nature';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ready as cryptoReady, tcrypto } from '@tanker/crypto';
import { expect } from '@tanker/test-utils';

import makeUint8Array from '../../__tests__/makeUint8Array';
import { makeUint8Array } from '../../__tests__/makeUint8Array';

import { serializeKeyPublish, unserializeKeyPublish, serializeKeyPublishToProvisionalUser, unserializeKeyPublishToProvisionalUser } from '../Serialize';

Expand Down
Loading

0 comments on commit 8839682

Please sign in to comment.