Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ exports.BlockstackContext = exports["default"] = void 0;

var _react = _interopRequireWildcard(require("react"));

var _blockstack = require("blockstack");
var _auth = require("@stacks/auth");

var _profile = require("@stacks/profile");

var _reactAtom = require("@dbeining/react-atom");

Expand All @@ -48,7 +50,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

Expand Down Expand Up @@ -118,7 +120,7 @@ function handleAuthenticated(userData) {
window.history.replaceState({}, document.title, window.location.pathname);
var update = {
userData: userData,
person: new _blockstack.Person(userData.profile),
person: new _profile.Person(userData.profile),
signIn: null,
authenticated: true,
signOut: signOut
Expand All @@ -132,7 +134,7 @@ function initBlockstack(options) {
userSession = _deref3.userSession;

if (!userSession) {
var _userSession = new _blockstack.UserSession(options);
var _userSession = new _auth.UserSession(options);

var update = {
userSession: _userSession
Expand Down Expand Up @@ -161,7 +163,7 @@ function initBlockstack(options) {

var _default = initBlockstack;
exports["default"] = _default;
var BlockstackContext = (0, _react.createContext)(defaultValue);
var BlockstackContext = /*#__PURE__*/(0, _react.createContext)(defaultValue);
exports.BlockstackContext = BlockstackContext;

function Blockstack(props) {
Expand Down Expand Up @@ -698,7 +700,7 @@ function useProfile(username, zoneFileLookupURL) {

(0, _react.useEffect)(function () {
if (userSession && username) {
(0, _blockstack.lookupProfile)(username, zoneFileLookupURL).then(setValue)["catch"](function (err) {
(0, _auth.lookupProfile)(username, zoneFileLookupURL).then(setValue)["catch"](function (err) {
return console.warn("Failed to use profile:", err);
});
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
},
"homepage": "https://github.com/njordhov/react-blockstack#readme",
"peerDependencies": {
"blockstack": "^21.0.0",
"@stacks/auth": "^1.0.0-beta.10",
"@stacks/profile": "^1.0.0-beta.10",
"react": "^16.8.0"
},
"dependencies": {
Expand Down
26 changes: 22 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
import React, { Component, createContext, useState, useEffect, useContext, useCallback, useReducer } from 'react'
import { UserSession, AppConfig, Person, lookupProfile } from 'blockstack'
import { Atom, swap, useAtom, deref} from "@dbeining/react-atom"
import { isNil, isNull, isEqual, isFunction, isUndefined, merge, set, identity } from 'lodash'
import React, {
Component,
createContext,
useState,
useEffect,
useContext,
useCallback,
useReducer,
} from "react";
import { UserSession, AppConfig, lookupProfile } from "@stacks/auth";
import { Person } from "@stacks/profile";
import { Atom, swap, useAtom, deref } from "@dbeining/react-atom";
import {
isNil,
isNull,
isEqual,
isFunction,
isUndefined,
merge,
set,
identity,
} from "lodash";

const defaultValue = {userData: null, signIn: null, signOut: null, authenticated: false}

Expand Down