Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cardcore/client

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cardcore/client - npm Package Compare versions

Comparing version 0.0.1-1f746c46 to 0.0.1-2bfe84b6

dist/client-poll.js

65

dist/client-actions.js

@@ -12,2 +12,16 @@ "use strict";

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _clientPoll = require("./client-poll");
Object.keys(_clientPoll).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _clientPoll[key];
}
});
});
var _game = require("@cardcore/game");

@@ -17,3 +31,3 @@

var _ssbKeys = require("ssb-keys");
var _ssbKeys = require("@streamplace/ssb-keys");

@@ -83,3 +97,3 @@ var _ssbKeys2 = _interopRequireDefault(_ssbKeys);

var CLIENT_PLAY_CREATURE = exports.CLIENT_PLAY_CREATURE = "CLIENT_PLAY_CREATURE";
var clientPlayCreature = exports.clientPlayCreature = function clientPlayCreature(card) {
var clientPlayCreature = exports.clientPlayCreature = function clientPlayCreature(boxId) {
return function () {

@@ -93,8 +107,8 @@ var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(dispatch, getState) {

state = getState();
unitId = (0, _util.traverseSecret)(card, state.secret);
unit = getState().game.units[unitId];
unitId = _util.Box.traverse(boxId, state.game.boxes, state.client.keys);
unit = state.game.units[unitId];
_context.next = 5;
return dispatch({
type: CLIENT_PLAY_CREATURE,
card: card,
boxId: boxId,
unit: unit

@@ -147,8 +161,4 @@ });

return function (dispatch, getState) {
var _getState$client = getState().client,
playingCard = _getState$client.playingCard,
targets = _getState$client.targets;
var privateKey = getState().secret[playingCard.id].private;
dispatch((0, _game.playCreature)({ id: playingCard.id, privateKey: privateKey, targets: targets }));
var boxId = getState().client.playingBoxId;
dispatch((0, _game.playCard)({ boxId: boxId }));
};

@@ -211,6 +221,37 @@ };

var CLIENT_GENERATE_IDENTITY = exports.CLIENT_GENERATE_IDENTITY = "CLIENT_GENERATE_IDENTITY";
var CARDCORE_IDENTITY = "CARDCORE_IDENTITY";
var clientGenerateIdentity = exports.clientGenerateIdentity = function clientGenerateIdentity() {
var storage = void 0;
if ((typeof localStorage === "undefined" ? "undefined" : _typeof(localStorage)) === "object") {
storage = localStorage;
} else {
// noop i guess? idk this only happens in jsdom?
storage = {
getItem: function getItem() {
return null;
},
setItem: function setItem() {
return null;
},
removeItem: function removeItem() {
return null;
}
};
}
var keys = void 0;
if (storage.getItem(CARDCORE_IDENTITY)) {
try {
keys = JSON.parse(storage.getItem(CARDCORE_IDENTITY));
} catch (e) {
console.error("error parsing cardcore identity, clearing", e);
storage.removeItem(CARDCORE_IDENTITY);
}
}
if (!keys) {
keys = _ssbKeys2.default.generate();
storage.setItem(CARDCORE_IDENTITY, JSON.stringify(keys));
}
return {
type: CLIENT_GENERATE_IDENTITY,
keys: _ssbKeys2.default.generate()
keys: keys
};

@@ -217,0 +258,0 @@ };

@@ -25,7 +25,8 @@ "use strict";

desyncStates: {},
playingCard: null,
playingBoxId: null,
targetQueue: [],
targets: [],
keys: {},
started: false
started: false,
loadingState: true
};

@@ -51,3 +52,3 @@

}),
playingCard: action.card
playingBoxId: action.boxId
});

@@ -61,3 +62,3 @@ }

availableTargets: null,
playingCard: null
playingBoxId: null
});

@@ -85,2 +86,14 @@ }

if (action.type === clientActions.CLIENT_LOAD_STATE_START) {
return Object.assign({}, state, {
loadingState: true
});
}
if (action.type === clientActions.CLIENT_LOAD_STATE_DONE || action.type === actions.CREATE_GAME) {
return Object.assign({}, state, {
loadingState: false
});
}
if (action.type === actions.PLAY_CREATURE) {

@@ -87,0 +100,0 @@ return Object.assign({}, state, {

{
"name": "@cardcore/client",
"version": "0.0.1-1f746c46",
"version": "0.0.1-2bfe84b6",
"description": "streamcards client",

@@ -13,3 +13,10 @@ "main": "dist/index.js",

},
"gitHead": "1f746c46c9911e36a1e9be89edf6da902e8ff20f"
"dependencies": {
"@cardcore/game": "0.0.1-2bfe84b6",
"@cardcore/util": "0.0.1-2bfe84b6",
"@streamplace/ssb-keys": "7.0.18",
"babel-runtime": "^6.26.0",
"cardcore": "0.0.1-2bfe84b6"
},
"gitHead": "2bfe84b63d6352d5a91c2ba8a0e0afc41e6798e5"
}

49

src/client-actions.js

@@ -1,4 +0,7 @@

import { playCreature } from "@cardcore/game";
import { traverseSecret, target as targetHelper } from "@cardcore/util";
import ssbKeys from "ssb-keys";
import { playCard } from "@cardcore/game";
import { Box, target as targetHelper } from "@cardcore/util";
import ssbKeys from "@streamplace/ssb-keys";
export * from "./client-poll";
/**

@@ -57,9 +60,9 @@ * This file should contain web-specific actions extranious to the game state

export const CLIENT_PLAY_CREATURE = "CLIENT_PLAY_CREATURE";
export const clientPlayCreature = card => async (dispatch, getState) => {
export const clientPlayCreature = boxId => async (dispatch, getState) => {
const state = getState();
const unitId = traverseSecret(card, state.secret);
const unit = getState().game.units[unitId];
const unitId = Box.traverse(boxId, state.game.boxes, state.client.keys);
const unit = state.game.units[unitId];
await dispatch({
type: CLIENT_PLAY_CREATURE,
card,
boxId,
unit

@@ -76,5 +79,4 @@ });

export const clientPlayCreatureDone = () => (dispatch, getState) => {
const { playingCard, targets } = getState().client;
const privateKey = getState().secret[playingCard.id].private;
dispatch(playCreature({ id: playingCard.id, privateKey, targets }));
const boxId = getState().client.playingBoxId;
dispatch(playCard({ boxId }));
};

@@ -111,6 +113,31 @@

export const CLIENT_GENERATE_IDENTITY = "CLIENT_GENERATE_IDENTITY";
const CARDCORE_IDENTITY = "CARDCORE_IDENTITY";
export const clientGenerateIdentity = () => {
let storage;
if (typeof localStorage === "object") {
storage = localStorage;
} else {
// noop i guess? idk this only happens in jsdom?
storage = {
getItem: () => null,
setItem: () => null,
removeItem: () => null
};
}
let keys;
if (storage.getItem(CARDCORE_IDENTITY)) {
try {
keys = JSON.parse(storage.getItem(CARDCORE_IDENTITY));
} catch (e) {
console.error("error parsing cardcore identity, clearing", e);
storage.removeItem(CARDCORE_IDENTITY);
}
}
if (!keys) {
keys = ssbKeys.generate();
storage.setItem(CARDCORE_IDENTITY, JSON.stringify(keys));
}
return {
type: CLIENT_GENERATE_IDENTITY,
keys: ssbKeys.generate()
keys
};

@@ -117,0 +144,0 @@ };

@@ -7,7 +7,8 @@ import * as actions from "@cardcore/game";

desyncStates: {},
playingCard: null,
playingBoxId: null,
targetQueue: [],
targets: [],
keys: {},
started: false
started: false,
loadingState: true
};

@@ -30,3 +31,3 @@

targetQueue: action.unit.onSummon.map(onSummon => onSummon.target),
playingCard: action.card
playingBoxId: action.boxId
};

@@ -41,3 +42,3 @@ }

availableTargets: null,
playingCard: null
playingBoxId: null
};

@@ -71,2 +72,19 @@ }

if (action.type === clientActions.CLIENT_LOAD_STATE_START) {
return {
...state,
loadingState: true
};
}
if (
action.type === clientActions.CLIENT_LOAD_STATE_DONE ||
action.type === actions.CREATE_GAME
) {
return {
...state,
loadingState: false
};
}
if (action.type === actions.PLAY_CREATURE) {

@@ -73,0 +91,0 @@ return {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc