@shopify/shopify-app-session-storage-memory 0.0.0-experimental-20240118200208

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-present, Shopify Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # In-Memory Session Storage
2
+
3
+ This package implements the `SessionStorage` interface to work with an in-memory storage table.
4
+
5
+ ```js
6
+ import {shopifyApp} from '@shopify/shopify-app-express';
7
+ import {MemorySessionStorage} from '@shopify/shopify-app-session-storage-memory';
8
+
9
+ const shopify = shopifyApp({
10
+ sessionStorage: new MemorySessionStorage(),
11
+ // ...
12
+ });
13
+ ```
14
+
15
+ > **Note**: :warning: This session storage model is for local development only, to make it easier for developers to get started.
16
+ > It will delete all sessions if the app process gets restarted or redeployed, and is not meant for production use.
17
+ > For persistent storage, use one of the other options (see relevant section above for instructions).
18
+
19
+ If you prefer to use your own implementation of a session storage mechanism that is compatible with the `@shopify/shopify-app-express` package, see the [implementing session storage guide](https://github.com/Shopify/shopify-app-js/blob/main/packages/shopify-app-session-storage/implementing-session-storage.md).
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ class MemorySessionStorage {
6
+ constructor() {
7
+ this.sessions = {};
8
+ }
9
+ async storeSession(session) {
10
+ this.sessions[session.id] = session;
11
+ return true;
12
+ }
13
+ async loadSession(id) {
14
+ return this.sessions[id] || undefined;
15
+ }
16
+ async deleteSession(id) {
17
+ if (this.sessions[id]) {
18
+ delete this.sessions[id];
19
+ }
20
+ return true;
21
+ }
22
+ async deleteSessions(ids) {
23
+ ids.forEach(id => delete this.sessions[id]);
24
+ return true;
25
+ }
26
+ async findSessionsByShop(shop) {
27
+ const results = Object.values(this.sessions).filter(session => session.shop === shop);
28
+ return results;
29
+ }
30
+ }
31
+
32
+ exports.MemorySessionStorage = MemorySessionStorage;
@@ -0,0 +1,11 @@
1
+ import { Session } from '@shopify/shopify-api';
2
+ import { SessionStorage } from '@shopify/shopify-app-session-storage';
3
+ export declare class MemorySessionStorage implements SessionStorage {
4
+ private sessions;
5
+ storeSession(session: Session): Promise<boolean>;
6
+ loadSession(id: string): Promise<Session | undefined>;
7
+ deleteSession(id: string): Promise<boolean>;
8
+ deleteSessions(ids: string[]): Promise<boolean>;
9
+ findSessionsByShop(shop: string): Promise<Session[]>;
10
+ }
11
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AAEpE,qBAAa,oBAAqB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ,CAA+B;IAElC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAKhD,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAIrD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO3C,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/C,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAMlE"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MemorySessionStorage = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var MemorySessionStorage = /** @class */ (function () {
6
+ function MemorySessionStorage() {
7
+ this.sessions = {};
8
+ }
9
+ MemorySessionStorage.prototype.storeSession = function (session) {
10
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
11
+ return tslib_1.__generator(this, function (_a) {
12
+ this.sessions[session.id] = session;
13
+ return [2 /*return*/, true];
14
+ });
15
+ });
16
+ };
17
+ MemorySessionStorage.prototype.loadSession = function (id) {
18
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
19
+ return tslib_1.__generator(this, function (_a) {
20
+ return [2 /*return*/, this.sessions[id] || undefined];
21
+ });
22
+ });
23
+ };
24
+ MemorySessionStorage.prototype.deleteSession = function (id) {
25
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
26
+ return tslib_1.__generator(this, function (_a) {
27
+ if (this.sessions[id]) {
28
+ delete this.sessions[id];
29
+ }
30
+ return [2 /*return*/, true];
31
+ });
32
+ });
33
+ };
34
+ MemorySessionStorage.prototype.deleteSessions = function (ids) {
35
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
36
+ var _this = this;
37
+ return tslib_1.__generator(this, function (_a) {
38
+ ids.forEach(function (id) { return delete _this.sessions[id]; });
39
+ return [2 /*return*/, true];
40
+ });
41
+ });
42
+ };
43
+ MemorySessionStorage.prototype.findSessionsByShop = function (shop) {
44
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
45
+ var results;
46
+ return tslib_1.__generator(this, function (_a) {
47
+ results = Object.values(this.sessions).filter(function (session) { return session.shop === shop; });
48
+ return [2 /*return*/, results];
49
+ });
50
+ });
51
+ };
52
+ return MemorySessionStorage;
53
+ }());
54
+ exports.MemorySessionStorage = MemorySessionStorage;
55
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/memory.ts"],"names":[],"mappings":";;;;AAGA;IAAA;QACU,aAAQ,GAA4B,EAAE,CAAC;IA6BjD,CAAC;IA3Bc,2CAAY,GAAzB,UAA0B,OAAgB;;;gBACxC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;gBACpC,sBAAO,IAAI,EAAC;;;KACb;IAEY,0CAAW,GAAxB,UAAyB,EAAU;;;gBACjC,sBAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,SAAS,EAAC;;;KACvC;IAEY,4CAAa,GAA1B,UAA2B,EAAU;;;gBACnC,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;oBACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;iBAC1B;gBACD,sBAAO,IAAI,EAAC;;;KACb;IAEY,6CAAc,GAA3B,UAA4B,GAAa;;;;gBACvC,GAAG,CAAC,OAAO,CAAC,UAAC,EAAE,IAAK,OAAA,OAAO,KAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAxB,CAAwB,CAAC,CAAC;gBAC9C,sBAAO,IAAI,EAAC;;;KACb;IAEY,iDAAkB,GAA/B,UAAgC,IAAY;;;;gBACpC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CACjD,UAAC,OAAO,IAAK,OAAA,OAAO,CAAC,IAAI,KAAK,IAAI,EAArB,CAAqB,CACnC,CAAC;gBACF,sBAAO,OAAO,EAAC;;;KAChB;IACH,2BAAC;AAAD,CAAC,AA9BD,IA8BC;AA9BY,oDAAoB"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@shopify/shopify-app-session-storage-memory",
3
+ "version": "0.0.0-experimental-20240118200208",
4
+ "description": "Shopify App Session Storage for Memory",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Shopify/shopify-app-js.git"
8
+ },
9
+ "bugs": {
10
+ "url": "https://github.com/Shopify/shopify-app-js/issues"
11
+ },
12
+ "homepage": "https://github.com/Shopify/shopify-app-js/tree/main/packages/shopify-app-session-storage-memory",
13
+ "author": "Shopify Inc.",
14
+ "license": "MIT",
15
+ "main": "./build/cjs/memory.js",
16
+ "types": "./build/ts/memory.d.ts",
17
+ "scripts": {},
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "keywords": [
22
+ "shopify",
23
+ "node",
24
+ "app",
25
+ "graphql",
26
+ "rest",
27
+ "webhook",
28
+ "Admin API",
29
+ "Storefront API",
30
+ "session storage"
31
+ ],
32
+ "dependencies": {
33
+ "tslib": "^2.6.2"
34
+ },
35
+ "peerDependencies": {
36
+ "@shopify/shopify-api": "^9.0.2",
37
+ "@shopify/shopify-app-session-storage": "0.0.0-experimental-20240118200208"
38
+ },
39
+ "devDependencies": {
40
+ "@shopify/eslint-plugin": "^42.1.0",
41
+ "@shopify/prettier-config": "^1.1.2",
42
+ "@shopify/shopify-app-session-storage-test-utils": "0.0.0-experimental-20240118200208",
43
+ "@types/jest": "^29.5.1",
44
+ "eslint": "^8.55.0",
45
+ "eslint-plugin-prettier": "^4.2.1",
46
+ "prettier": "^2.8.8",
47
+ "typescript": "4.9.5"
48
+ },
49
+ "files": [
50
+ "build/*",
51
+ "!bundle/*",
52
+ "!tsconfig.tsbuildinfo",
53
+ "!node_modules"
54
+ ]
55
+ }