# cc-sharing

> communication between sharinator iframes ...

Latest version **1.0.12** (published 2017-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install cc-sharing
pnpm add cc-sharing
yarn add cc-sharing
bun add cc-sharing
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2017-10-10 |
| First published | 2017-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Noah Paessel npaessel@concord.org |
| Maintainers | knowuh |

## Links

- npm: https://www.npmjs.com/package/cc-sharing
- Repository: https://github.com/concord-consortium/cc-sharing-lib
- Homepage: https://github.com/concord-consortium/cc-sharing-lib#readme
- Issues: https://github.com/concord-consortium/cc-sharing-lib/issues
- npm.io page: https://npm.io/package/cc-sharing

## Dependencies (4)

- [uuid](https://npm.io/package/uuid.md) ^3.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [semver](https://npm.io/package/semver.md) ^5.3.0
- [iframe-phone](https://npm.io/package/iframe-phone.md) ^1.2.0

## Recent versions

- 1.0.12 (latest) — 2017-10-10
- 1.0.11 — 2017-09-27
- 1.0.10 — 2017-09-27
- 1.0.9 — 2017-09-21
- 1.0.8 — 2017-09-20
- 1.0.7 — 2017-09-20
- 1.0.6 — 2017-09-13
- 1.0.5 — 2017-09-12
- 1.0.4 — 2017-09-12
- 1.0.3 — 2017-09-11
- 1.0.2 — 2017-09-06
- 1.0.1 — 2017-08-31
- 1.0.0 — 2017-08-30

## README

## cc-sharing client library ##

To be used by clients of the CC [Sharintor](https://github.com/concord-consortium/sharinator)

This library defines [iFramePhone](https://github.com/concord-consortium/iframe-phone) message signatures
for the purpose of 'sharing' work between students and teachers.

## Details ##

There are four message types defined:

1. `SharinatorInit`
    * Sends data about the session in `sharing-init` format
1. `SharinitorInitResponse`
    * Sends data about the session in `sharing-init` format
2. `SharinatorPublish`
    * User intiated request for new data.
3. `SharinatorPublishResponse`
    * Contents of publishable data in `Publishable` format.


## To Build: ##
1. Install dependencies: `yarn`
2. Compile `npm run build`


## Using this library
All of this subject to change out of the blue. As of 2017-09-06 the easiest / best thing to do
is something like this:

```
    const context:Context = {
        protocolVersion: "1.0.0",
        user: 1, // <string>|<number>
        id: uuid.v1(),
        group: 2, // <string>|<number>
        offering: 3, // <string>|<number>
        class: 4, // <string>|<number>
        requestTime: new Date().toISOString()
    };

    const app:SharableApp = {
        // Describe the application:
        application: {
            launchUrl: "http://127.0.0.1:8080/src/demo/iframe.html",
            name: "demo iframe app"
        },

        getDataFunc: (context) => {
            // 1. Construct a unique url from the sharing context:
            const dataUrl = `${context.group.id}-${context.offering.id}-${context.user.id}`;
            // 2. The promise constructs a list of data Represnetations:
            return new Promise((resolve, reject) => {
                resolve([
                {
                    type: Text,
                    dataUrl: `this is the iframe response at ${new Date()}`
                }
                ]);
            });
        }
    };

    // Pass in an existing phone as first arg if you want to reuse it.
    sharing = new SharingRelay({app:app});
    const receivePub = (snapshot:PublishResponse) => console.log(snapshot);
    sharing.addPublicationListener({newPublication: receivePub});
    sharing.initializeAsTop(context);

```

## Running the demo & tester app ##

You can view an [online demo](http://sharing-demo.concord.org/branch/master/index.html).

You can epxierment with that demo by cloning the gihub repo [cc-sharing-demo](https://github.com/concord-consortium/cc-sharing-demo)

See that README document for more info.


## Rough Messaging Diagram

![messaging diagram](sharing.jpg)

---
_Source: https://npm.io/package/cc-sharing · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
