Skip to content

Commit

Permalink
Only export CommonJS modules to avoid dual-publish issues (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulLeCam authored Feb 25, 2022
1 parent 489862b commit 66eb5d9
Show file tree
Hide file tree
Showing 53 changed files with 3,914 additions and 4,612 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SelfID

Monorepo for the SelfID [application](#application) and [SDK](#sdk).
Monorepo for the SelfID [SDK](#sdk) and [reference application](#application).

## Installation

Expand Down Expand Up @@ -60,10 +60,11 @@ Predefined setups using common technologies to build applications using the Self
| Name | Description |
| ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| [`next-notes-typescript`](./templates/next-notes-typescript) | Notes taking application setup using [Next.js](https://nextjs.org/) and [TypeScript](https://www.typescriptlang.org/) |
| [`vite-basic`](./templates/vite-basic) | Basic [Vite](https://vitejs.dev/) setup |
| [`webpack-basic`](./templates/webpack-basic) | Basic [Webpack](https://webpack.js.org/) setup |
| [`webpack-basic-typescript`](./templates/webpack-basic-typescript) | Basic [Webpack](https://webpack.js.org/) setup using [TypeScript](https://www.typescriptlang.org/) |

<!-- | [`vite-basic`](./templates/vite-basic) | Basic [Vite](https://vitejs.dev/) setup | -->

## Maintainers

- Paul Le Cam ([@paullecam](http://github.com/paullecam))
Expand Down
8 changes: 4 additions & 4 deletions apps/developers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"--build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
Expand All @@ -14,8 +14,8 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "2.0.0-beta.9",
"@docusaurus/preset-classic": "2.0.0-beta.9",
"@docusaurus/core": "2.0.0-beta.15",
"@docusaurus/preset-classic": "2.0.0-beta.15",
"@docusaurus/theme-live-codeblock": "^2.0.0-beta.9",
"@mdx-js/react": "^1.6.21",
"@self.id/docusaurus-plugin": "^0.1.0",
Expand Down Expand Up @@ -48,7 +48,7 @@
"@types/react": "^17.0.37",
"@types/react-helmet": "^6.1.3",
"@types/react-router-dom": "^5.3.2",
"docusaurus-plugin-typedoc": "^0.16.5",
"docusaurus-plugin-typedoc": "^0.17.0",
"typescript": "^4.5.2"
}
}
4 changes: 0 additions & 4 deletions apps/self.id/.babelrc

This file was deleted.

1 change: 0 additions & 1 deletion apps/self.id/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
Expand Down
3 changes: 3 additions & 0 deletions apps/self.id/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
})

module.exports = withBundleAnalyzer({
compiler: {
styledComponents: true,
},
async headers() {
return [
{
Expand Down
50 changes: 25 additions & 25 deletions apps/self.id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@
"start": "next start"
},
"dependencies": {
"@self.id/3box-legacy": "^0.1.0",
"@self.id/framework": "^0.1.0",
"copy-to-clipboard": "^3.3.1",
"grommet": "^2.19.1",
"next": "^12.0.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hot-toast": "^2.1.1",
"react-is": "^17.0.2",
"scheduler": "^0.20.2",
"styled-components": "^5.3.3",
"uint8arrays": "^3.0.0"
"@self.id/3box-legacy": "0.2.0",
"@self.id/framework": "0.2.0",
"@self.id/multiauth": "0.2.0",
"copy-to-clipboard": "3.3.1",
"grommet": "2.21.0",
"next": "12.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hot-toast": "2.2.0",
"react-is": "17.0.2",
"scheduler": "0.20.2",
"styled-components": "5.3.3",
"uint8arrays": "3.0.0"
},
"devDependencies": {
"@next/bundle-analyzer": "^12.0.4",
"@self.id/multiauth": "^0.1.0",
"@types/node": "^16.11.11",
"@types/pica": "^5.1.3",
"@types/react": "^17.0.37",
"@types/styled-components": "^5.1.15",
"babel-plugin-styled-components": "^2.0.2",
"eslint": "^8.3.0",
"eslint-config-3box": "^0.4.0",
"eslint-config-next": "^12.0.4",
"key-did-provider-ed25519": "^1.1.0",
"prettier": "^2.5.0",
"typescript": "^4.5.2"
"@next/bundle-analyzer": "12.1.0",
"@types/node": "17.0.21",
"@types/pica": "9.0.0",
"@types/react": "17.0.39",
"@types/styled-components": "5.1.23",
"babel-plugin-styled-components": "2.0.5",
"eslint": "8.9.0",
"eslint-config-3box": "0.4.1",
"eslint-config-next": "12.1.0",
"key-did-provider-ed25519": "1.1.0",
"prettier": "2.5.1",
"typescript": "4.5.5"
}
}
15 changes: 14 additions & 1 deletion apps/self.id/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import type { PartialConnectorConfig, PartialNetworkConfig } from '@self.id/multiauth'
import ethereumLogo from '@self.id/multiauth/assets/ethereum.png'
import fortmaticLogo from '@self.id/multiauth/assets/fortmatic.png'
import metaMaskLogo from '@self.id/multiauth/assets/metamask.png'
import portisLogo from '@self.id/multiauth/assets/portis.png'
import torusLogo from '@self.id/multiauth/assets/torus.png'
import walletConnectLogo from '@self.id/multiauth/assets/walletconnect.png'

const ethereumConnectors: Array<PartialConnectorConfig> = [{ key: 'injected' }]
const ethereumConnectors: Array<PartialConnectorConfig> = [
{ key: 'injected', logo: metaMaskLogo.src },
]

const walletConnectChainId = process.env.NEXT_PUBLIC_WALLETCONNECT_CHAIN_ID
const walletConnectRpcUrl = process.env.NEXT_PUBLIC_WALLETCONNECT_RPC_URL
if (typeof walletConnectChainId === 'string' && typeof walletConnectRpcUrl === 'string') {
ethereumConnectors.push({
key: 'walletConnect',
logo: walletConnectLogo.src,
params: {
rpc: { [walletConnectChainId]: walletConnectRpcUrl },
},
Expand All @@ -18,6 +27,7 @@ const fortmaticChainId = process.env.NEXT_PUBLIC_FORTMATIC_CHAIN_ID
if (typeof fortmaticApiKey === 'string' && typeof fortmaticChainId === 'string') {
ethereumConnectors.push({
key: 'fortmatic',
logo: fortmaticLogo.src,
params: {
apiKey: fortmaticApiKey,
},
Expand All @@ -29,6 +39,7 @@ const portisNetwork = process.env.NEXT_PUBLIC_PORTIS_NETWORK
if (typeof portisDappId === 'string' && typeof portisNetwork === 'string') {
ethereumConnectors.push({
key: 'portis',
logo: portisLogo.src,
params: {
dAppId: portisDappId,
network: portisNetwork,
Expand All @@ -40,6 +51,7 @@ const torusNetworkHost = process.env.NEXT_PUBLIC_TORUS_NETWORK_HOST
if (typeof torusNetworkHost === 'string') {
ethereumConnectors.push({
key: 'torus',
logo: torusLogo.src,
params: {
network: { host: torusNetworkHost },
},
Expand All @@ -49,6 +61,7 @@ if (typeof torusNetworkHost === 'string') {
export const networks: Array<PartialNetworkConfig> = [
{
key: 'ethereum',
logo: ethereumLogo.src,
connectors: ethereumConnectors,
},
]
18 changes: 15 additions & 3 deletions apps/self.id/src/components/client/EditProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,29 @@ function profileToForm({ nationalities, ...profile }: BasicProfile): FormValue {
return { ...profile, nationality: nationalities?.[0] }
}

function changeProfile(profile: BasicProfile, { nationality, ...value }: FormValue): BasicProfile {
function changeProfile(
profile: BasicProfile,
{ nationality, residenceCountry, ...value }: FormValue
): BasicProfile {
const changed = { ...profile, ...value }

// Turn single-value nationality into array, with uppercase value
const nationalities = profile.nationalities
if (nationality && Array.isArray(nationalities) && !nationalities.includes(nationality)) {
nationalities.unshift(nationality)
if (nationality && Array.isArray(nationalities)) {
const formattedNationality = nationality.toUpperCase()
if (!nationalities.includes(formattedNationality)) {
nationalities.unshift(formattedNationality)
}
}
if (nationalities?.length) {
changed.nationalities = nationalities
}

// Residence country code must be uppercase
if (residenceCountry != null && residenceCountry !== '') {
changed.residenceCountry = residenceCountry.toUpperCase()
}

return changed
}

Expand Down
5 changes: 3 additions & 2 deletions apps/self.id/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Provider } from '@self.id/framework'

import closeIcon from '@self.id/multiauth/assets/icon-close.svg'
import selectedIcon from '@self.id/multiauth/assets/icon-selected.svg'
import type { AppProps } from 'next/app'
import Head from 'next/head'
import { Toaster } from 'react-hot-toast'
Expand Down Expand Up @@ -50,7 +51,7 @@ export default function App({ Component, pageProps }: AppProps): JSX.Element {

return (
<Provider
auth={{ networks }}
auth={{ networks, modal: { closeIcon: closeIcon.src, selectedIcon: selectedIcon.src } }}
client={{ ceramic: CERAMIC_URL, connectNetwork: CONNECT_NETWORK }}
state={state}
ui={{ full: true }}>
Expand Down
7 changes: 2 additions & 5 deletions packages/3box-legacy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@self.id/3box-legacy",
"version": "0.1.0",
"version": "0.2.0",
"author": "3Box Labs",
"license": "(Apache-2.0 OR MIT)",
"homepage": "https://github.com/ceramicstudio/self.id#readme",
Expand All @@ -14,10 +14,8 @@
"directory": "packages/3box-legacy"
},
"main": "dist/lib.cjs",
"module": "dist/lib.mjs",
"typings": "dist/index.d.ts",
"exports": {
"import": "./dist/lib.mjs",
"require": "./dist/lib.cjs",
"default": "./dist/lib.cjs"
},
Expand All @@ -33,8 +31,7 @@
"build": "del dist && tsc --emitDeclarationOnly --skipLibCheck && rollup -c ../../rollup.config.js",
"lint": "eslint --fix",
"test": "jest",
"prepare": "yarn build",
"prepublishOnly": "package-check"
"prepare": "yarn build"
},
"dependencies": {
"cross-fetch": "^3.1.4"
Expand Down
7 changes: 2 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@self.id/core",
"version": "0.2.0",
"version": "0.3.0",
"author": "3Box Labs",
"license": "(Apache-2.0 OR MIT)",
"homepage": "https://github.com/ceramicstudio/self.id#readme",
Expand All @@ -14,10 +14,8 @@
"directory": "packages/core"
},
"main": "dist/lib.cjs",
"module": "dist/lib.mjs",
"typings": "dist/index.d.ts",
"exports": {
"import": "./dist/lib.mjs",
"require": "./dist/lib.cjs",
"default": "./dist/lib.cjs"
},
Expand All @@ -34,8 +32,7 @@
"build": "del dist && tsc --emitDeclarationOnly --skipLibCheck && rollup -c ../../rollup.config.js",
"lint": "eslint --fix",
"test": "jest",
"prepare": "yarn build",
"prepublishOnly": "package-check"
"prepare": "yarn build"
},
"dependencies": {
"@ceramicnetwork/3id-did-resolver": "^1.4.9",
Expand Down
24 changes: 12 additions & 12 deletions packages/framework/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@self.id/framework",
"version": "0.1.0",
"version": "0.2.0",
"author": "3Box Labs",
"license": "(Apache-2.0 OR MIT)",
"homepage": "https://github.com/ceramicstudio/self.id#readme",
Expand All @@ -15,10 +15,8 @@
"directory": "packages/framework"
},
"main": "dist/lib.cjs",
"module": "dist/lib.mjs",
"typings": "dist/index.d.ts",
"exports": {
"import": "./dist/lib.mjs",
"require": "./dist/lib.cjs",
"default": "./dist/lib.cjs"
},
Expand All @@ -34,18 +32,17 @@
"build": "del dist && tsc --emitDeclarationOnly --skipLibCheck && rollup -c ../../rollup.config.js",
"lint": "eslint --fix",
"test": "jest",
"prepare": "yarn build",
"prepublishOnly": "package-check"
"prepare": "yarn build"
},
"dependencies": {
"@datamodels/identity-accounts-web": "^0.1.2",
"@datamodels/identity-profile-basic": "^0.1.2",
"@self.id/core": "^0.2.0",
"@self.id/image-utils": "^0.1.0",
"@self.id/multiauth": "^0.1.0",
"@self.id/react": "^0.1.0",
"@self.id/ui": "^0.1.0",
"@self.id/web": "^0.2.0",
"@self.id/core": "^0.3.0",
"@self.id/image-utils": "^0.2.0",
"@self.id/multiauth": "^0.2.0",
"@self.id/react": "^0.2.0",
"@self.id/ui": "^0.2.0",
"@self.id/web": "^0.3.0",
"boring-avatars": "^1.5.8",
"grommet": "^2.19.1"
},
Expand All @@ -56,6 +53,9 @@
"react": "^17.0.2"
},
"jest": {
"preset": "ts-jest"
"preset": "ts-jest",
"moduleNameMapper": {
"\\.(png|svg)$": "<rootDir>/test/__mocks__/fileMock.js"
}
}
}
1 change: 1 addition & 0 deletions packages/framework/test/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = ''
9 changes: 3 additions & 6 deletions packages/image-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@self.id/image-utils",
"version": "0.1.0",
"version": "0.2.0",
"author": "3Box Labs",
"license": "(Apache-2.0 OR MIT)",
"homepage": "https://github.com/ceramicstudio/self.id#readme",
Expand All @@ -14,10 +14,8 @@
"directory": "packages/image-utils"
},
"main": "dist/lib.cjs",
"module": "dist/lib.mjs",
"typings": "dist/index.d.ts",
"exports": {
"import": "./dist/lib.mjs",
"require": "./dist/lib.cjs",
"default": "./dist/lib.cjs"
},
Expand All @@ -32,11 +30,10 @@
"scripts": {
"build": "del dist && tsc --emitDeclarationOnly --skipLibCheck && rollup -c ../../rollup.config.js",
"lint": "eslint --fix",
"prepare": "yarn build",
"prepublishOnly": "package-check"
"prepare": "yarn build"
},
"dependencies": {
"pica": "^8.0.0"
"pica": "^9.0.1"
},
"devDependencies": {
"@datamodels/identity-profile-basic": "^0.1.2"
Expand Down
Loading

0 comments on commit 66eb5d9

Please sign in to comment.