Skip to content

Commit

Permalink
fix: lint prettier all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
aulneau committed Oct 2, 2020
1 parent 9a6ad14 commit 17fc891
Show file tree
Hide file tree
Showing 60 changed files with 5,053 additions and 4,845 deletions.
29 changes: 14 additions & 15 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
module.exports = function (api) {

module.exports = function(api) {
// TODO: Should cache on api.caller and api.env for faster build times.
api.cache.invalidate(() => true);

const isTestEnv = api.env("test");
const isDevEnv = api.env("development");
const isTestEnv = api.env('test');
const isDevEnv = api.env('development');

// Babel config for web browser lib dist with wide-spread browser support.
let opts = {
presets: [
["@babel/preset-env", {
"targets": {
"esmodules": true
}
}]
[
'@babel/preset-env',
{
targets: {
esmodules: true,
},
},
],
],
plugins: [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
]
plugins: ['@babel/proposal-class-properties', '@babel/proposal-object-rest-spread'],
};

// Use full source maps in development env.
if (!opts.sourceMaps && isDevEnv) {
opts.sourceMaps = "both";
opts.sourceMaps = 'both';
}

return opts;
}
};
52 changes: 26 additions & 26 deletions packages/auth/src/appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

import { DEFAULT_SCOPE, DEFAULT_BLOCKSTACK_HOST, AuthScope } from './constants'
import { getGlobalObject } from '@stacks/common'
import { DEFAULT_SCOPE, DEFAULT_BLOCKSTACK_HOST, AuthScope } from './constants';
import { getGlobalObject } from '@stacks/common';

/**
* Configuration data for the current app.
Expand All @@ -10,28 +9,27 @@ import { getGlobalObject } from '@stacks/common'
* `window.location.origin` as the app domain.
* On non-browser platforms, you need to
* specify an app domain as the second argument.
*
*
*/
export class AppConfig {
/**
* Blockstack apps are uniquely identified by their app domain.
*
*/
appDomain: string
appDomain: string;

/**
* An array of string representing permissions requested by the app.
*
*/
scopes: Array<AuthScope | string>

scopes: Array<AuthScope | string>;

/**
* Path on app domain to redirect users to after authentication. The
* authentication response token will be postpended in a query.
*
*/
redirectPath: string
redirectPath: string;

/**
* Path relative to app domain of app's manifest file.
Expand All @@ -40,45 +38,47 @@ export class AppConfig {
* from any origin. Typically this means return the header `Access-Control-Allow-Origin: *`.
*
*/
manifestPath: string
manifestPath: string;

/**
* The URL of Blockstack core node to use for this app. If this is
* `null`, the core node specified by the user or default core node
* will be used.
*
*/
coreNode: string
coreNode: string;

/**
* The URL of a web-based Blockstack Authenticator to use in the event
* the user doesn't have Blockstack installed on their machine. If this
* is not specified, the current default in this library will be used.
*
*/
authenticatorURL?: string
authenticatorURL?: string;

/**
* @param {Array<string>} scopes - permissions this app is requesting
* @param {string} appDomain - the app domain
* @param {string} redirectPath - path on app domain to redirect users to after authentication
* @param {string} manifestPath - path relative to app domain of app's manifest file
* @param {string} coreNode - override the default or user selected core node
* @param {string} authenticatorURL - the web-based fall back authenticator
* @param {string} authenticatorURL - the web-based fall back authenticator
* ([[DEFAULT_BLOCKSTACK_HOST]])
*/
constructor(scopes: Array<string> = DEFAULT_SCOPE.slice(),
appDomain: string = getGlobalObject('location', { returnEmptyObject: true }).origin,
redirectPath: string = '',
manifestPath: string = '/manifest.json',
coreNode: string | null = null,
authenticatorURL: string = DEFAULT_BLOCKSTACK_HOST) {
this.appDomain = appDomain
this.scopes = scopes
this.redirectPath = redirectPath
this.manifestPath = manifestPath
this.coreNode = coreNode
this.authenticatorURL = authenticatorURL
constructor(
scopes: Array<string> = DEFAULT_SCOPE.slice(),
appDomain: string = getGlobalObject('location', { returnEmptyObject: true }).origin,
redirectPath: string = '',
manifestPath: string = '/manifest.json',
coreNode: string | null = null,
authenticatorURL: string = DEFAULT_BLOCKSTACK_HOST
) {
this.appDomain = appDomain;
this.scopes = scopes;
this.redirectPath = redirectPath;
this.manifestPath = manifestPath;
this.coreNode = coreNode;
this.authenticatorURL = authenticatorURL;
}

/**
Expand All @@ -87,14 +87,14 @@ export class AppConfig {
* @returns {string} - URI
*/
redirectURI(): string {
return `${this.appDomain}${this.redirectPath}`
return `${this.appDomain}${this.redirectPath}`;
}

/**
* The location of the app's manifest file.
* @returns {string} - URI
*/
manifestURI(): string {
return `${this.appDomain}${this.manifestPath}`
return `${this.appDomain}${this.manifestPath}`;
}
}
66 changes: 32 additions & 34 deletions packages/auth/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@

/**
* @ignore
*/
export const BLOCKSTACK_HANDLER = 'blockstack'
* @ignore
*/
export const BLOCKSTACK_HANDLER = 'blockstack';
/**
* @ignore
*/
export const BLOCKSTACK_STORAGE_LABEL = 'blockstack'
* @ignore
*/
export const BLOCKSTACK_STORAGE_LABEL = 'blockstack';
/**
* This constant is used in the [[redirectToSignInWithAuthRequest]]
*/
export const DEFAULT_BLOCKSTACK_HOST = 'https://browser.blockstack.org/auth'
* This constant is used in the [[redirectToSignInWithAuthRequest]]
*/
export const DEFAULT_BLOCKSTACK_HOST = 'https://browser.blockstack.org/auth';

/**
* Default user profile object
*/
* Default user profile object
*/
export const DEFAULT_PROFILE = {
'@type': 'Person',
'@context': 'http://schema.org'
}
'@context': 'http://schema.org',
};

/**
* Non-exhaustive list of common permission scopes.
* Non-exhaustive list of common permission scopes.
*/
export const enum AuthScope {
/**
Expand All @@ -31,36 +30,35 @@ export const enum AuthScope {
store_write = 'store_write',
/**
* Publish data so that other users of the app can discover and interact with the user.
* The user's files stored on Gaia hub are made visible to others via the `apps` property in the
* user’s `profile.json` file.
* The user's files stored on Gaia hub are made visible to others via the `apps` property in the
* user’s `profile.json` file.
*/
publish_data = 'publish_data',
/**
* Request the user's email if available.
*/
email = 'email'
email = 'email',
}


/**
* @ignore
*/
export const DEFAULT_SCOPE = [AuthScope.store_write]
* @ignore
*/
export const DEFAULT_SCOPE = [AuthScope.store_write];

/**
* @ignore
*/
export const BLOCKSTACK_APP_PRIVATE_KEY_LABEL = 'blockstack-transit-private-key'
* @ignore
*/
export const BLOCKSTACK_APP_PRIVATE_KEY_LABEL = 'blockstack-transit-private-key';

/**
* @ignore
*/
export const DEFAULT_CORE_NODE = 'https://core.blockstack.org'
* @ignore
*/
export const DEFAULT_CORE_NODE = 'https://core.blockstack.org';
/**
* @ignore
*/
export const NAME_LOOKUP_PATH = '/v1/names'
* @ignore
*/
export const NAME_LOOKUP_PATH = '/v1/names';
/**
* @ignore
*/
export const LOCALSTORAGE_SESSION_KEY = 'blockstack-session'
* @ignore
*/
export const LOCALSTORAGE_SESSION_KEY = 'blockstack-session';
40 changes: 20 additions & 20 deletions packages/auth/src/dids.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import { InvalidDIDError } from '@stacks/common'
import { InvalidDIDError } from '@stacks/common';

/**
* @ignore
*/
* @ignore
*/
export function makeDIDFromAddress(address: string) {
return `did:btc-addr:${address}`
return `did:btc-addr:${address}`;
}

/**
* @ignore
*/
* @ignore
*/
export function makeDIDFromPublicKey(publicKey: string) {
return `did:ecdsa-pub:${publicKey}`
return `did:ecdsa-pub:${publicKey}`;
}

/**
* @ignore
*/
* @ignore
*/
export function getDIDType(decentralizedID: string) {
const didParts = decentralizedID.split(':')
const didParts = decentralizedID.split(':');

if (didParts.length !== 3) {
throw new InvalidDIDError('Decentralized IDs must have 3 parts')
throw new InvalidDIDError('Decentralized IDs must have 3 parts');
}

if (didParts[0].toLowerCase() !== 'did') {
throw new InvalidDIDError('Decentralized IDs must start with "did"')
throw new InvalidDIDError('Decentralized IDs must start with "did"');
}

return didParts[1].toLowerCase()
return didParts[1].toLowerCase();
}

/**
* @ignore
*/
* @ignore
*/
export function getAddressFromDID(decentralizedID: string) {
const didType = getDIDType(decentralizedID)
const didType = getDIDType(decentralizedID);

if (didType === 'btc-addr') {
return decentralizedID.split(':')[2]
return decentralizedID.split(':')[2];
} else {
return null
return null;
}
}

Expand Down
40 changes: 19 additions & 21 deletions packages/auth/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
export { AppConfig } from './appConfig';
export { makeAuthRequest, makeAuthResponse } from './messages';
export { getAuthRequestFromURL, fetchAppManifest } from './provider';
export {
AppConfig
} from './appConfig'
export {
makeAuthRequest, makeAuthResponse
} from './messages'
export {
getAuthRequestFromURL, fetchAppManifest
} from './provider'
export {
verifyAuthRequest, verifyAuthResponse,
isExpirationDateValid, isIssuanceDateValid, doPublicKeysMatchUsername,
doPublicKeysMatchIssuer, doSignaturesMatchPublicKeys,
isManifestUriValid, isRedirectUriValid, verifyAuthRequestAndLoadManifest
} from './verification'
export * from './dids'
export {
UserSession
} from './userSession'
export * from './constants'
export * from './profile'
export * from './userData'
verifyAuthRequest,
verifyAuthResponse,
isExpirationDateValid,
isIssuanceDateValid,
doPublicKeysMatchUsername,
doPublicKeysMatchIssuer,
doSignaturesMatchPublicKeys,
isManifestUriValid,
isRedirectUriValid,
verifyAuthRequestAndLoadManifest,
} from './verification';
export * from './dids';
export { UserSession } from './userSession';
export * from './constants';
export * from './profile';
export * from './userData';

0 comments on commit 17fc891

Please sign in to comment.