Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
bvescovi-orangeloops committed Apr 10, 2023
1 parent 14ead60 commit 16bfe75
Show file tree
Hide file tree
Showing 34 changed files with 203 additions and 38 deletions.
4 changes: 2 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export default class LAMP {
static Auth: {
new (): {};
_auth: IAuth;
_me: Participant | Researcher | Researcher[];
_type: "admin" | "researcher" | "participant";
_me: Researcher[] | Researcher | Participant | null | undefined;
_type: "admin" | "researcher" | "participant" | null;
/**
* Authenticate/authorize as a user of a given `type`.
* If all values are null (especially `type`), the authorization is cleared.
Expand Down
20 changes: 14 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
Expand Down Expand Up @@ -35,18 +45,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = void 0;
require("isomorphic-fetch");
var index_1 = require("./service/index");
var Demo_1 = require("./service/Demo");
var Fetch_1 = require("./service/Fetch");
var jsonwebtoken_1 = require("jsonwebtoken");
__export(require("./service/index"));
__export(require("./model/index"));
__exportStar(require("./service/index"), exports);
__exportStar(require("./model/index"), exports);
//
var _bus = (_a = global.document) === null || _a === void 0 ? void 0 : _a.createElement("_lamp_fake");
/**
Expand Down Expand Up @@ -127,8 +135,8 @@ var LAMP = /** @class */ (function () {
* If all values are null (especially `type`), the authorization is cleared.
*/
class_1.set_identity = function (identity) {
if (identity === void 0) { identity = {}; }
var _a;
if (identity === void 0) { identity = {}; }
return __awaiter(this, void 0, void 0, function () {
var serverAddress, authorization, id, payload, typeData, e_1, _b, err_1;
return __generator(this, function (_c) {
Expand Down
1 change: 1 addition & 0 deletions dist/model/Activity.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Activity = exports.DurationIntervalLegacy = exports.DurationInterval = void 0;
/**
*
*/
Expand Down
1 change: 1 addition & 0 deletions dist/model/ActivityEvent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivityEvent = exports.TemporalEvent = void 0;
/**
* A specific sub-detail of a `ActivityEvent` that contains specific interaction information that comprises the parent `ActivityEvent`.
*/
Expand Down
1 change: 1 addition & 0 deletions dist/model/ActivitySpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivitySpec = void 0;
/**
* The ActivitySpec determines the parameters and properties of an Activity and its corresponding generated ActivityEvents.
*/
Expand Down
5 changes: 5 additions & 0 deletions dist/model/Credential.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PersonalAccessToken } from "./PersonalAccessToken";
/**
* Every object can have one or more credential(s) associated with it. i.e. my_researcher.credentials = ['person A', 'person B', 'api A', 'person C', 'api B']
*/
Expand All @@ -18,4 +19,8 @@ export declare class Credential {
* The user-visible description of the credential.
*/
description?: string;
/**
* The list of user-generated personal access token.
*/
tokens?: PersonalAccessToken[];
}
1 change: 1 addition & 0 deletions dist/model/Credential.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Credential = void 0;
/**
* Every object can have one or more credential(s) associated with it. i.e. my_researcher.credentials = ['person A', 'person B', 'api A', 'person C', 'api B']
*/
Expand Down
1 change: 1 addition & 0 deletions dist/model/DynamicAttachment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DynamicAttachment = void 0;
/**
*
*/
Expand Down
1 change: 1 addition & 0 deletions dist/model/Participant.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Participant = void 0;
/**
* A participant within a study a participant cannot be enrolled in more than one study at a time.
*/
Expand Down
18 changes: 18 additions & 0 deletions dist/model/PersonalAccessToken.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export declare class PersonalAccessToken {
/**
* The generated jwt, which contains the access key associated to the credential.
*/
token: string;
/**
* The user-visible description of the credential.
*/
description: string;
/**
* The timestamp on which the token was created.
*/
created: number;
/**
* The timestamp on which the token expires.
*/
expiry: number;
}
1 change: 1 addition & 0 deletions dist/model/Researcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Researcher = void 0;
/**
*
*/
Expand Down
1 change: 1 addition & 0 deletions dist/model/Sensor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Sensor = void 0;
/**
* A sensor that may or may not be available on a physical device.
*/
Expand Down
1 change: 1 addition & 0 deletions dist/model/SensorEvent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SensorEvent = void 0;
/**
* An event generated by a participant interacting with the LAMP app.
*/
Expand Down
1 change: 1 addition & 0 deletions dist/model/SensorSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SensorSpec = void 0;
/**
* The SensorSpec determines the parameters of generated SensorEvents.
*/
Expand Down
1 change: 1 addition & 0 deletions dist/model/Study.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Study = void 0;
/**
*
*/
Expand Down
1 change: 1 addition & 0 deletions dist/model/Type.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Document = exports.Metadata = exports.AccessCitation = void 0;
/**
*
*/
Expand Down
35 changes: 21 additions & 14 deletions dist/model/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./Activity"));
__export(require("./ActivityEvent"));
__export(require("./ActivitySpec"));
__export(require("./Credential"));
__export(require("./Participant"));
__export(require("./Researcher"));
__export(require("./Sensor"));
__export(require("./SensorEvent"));
__export(require("./SensorSpec"));
__export(require("./Study"));
__export(require("./Type"));
__exportStar(require("./Activity"), exports);
__exportStar(require("./ActivityEvent"), exports);
__exportStar(require("./ActivitySpec"), exports);
__exportStar(require("./Credential"), exports);
__exportStar(require("./Participant"), exports);
__exportStar(require("./Researcher"), exports);
__exportStar(require("./Sensor"), exports);
__exportStar(require("./SensorEvent"), exports);
__exportStar(require("./SensorSpec"), exports);
__exportStar(require("./Study"), exports);
__exportStar(require("./Type"), exports);
1 change: 1 addition & 0 deletions dist/service/API.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.APIService = void 0;
var Fetch_1 = require("./Fetch");
var index_1 = __importDefault(require("../index"));
var APIService = /** @class */ (function () {
Expand Down
1 change: 1 addition & 0 deletions dist/service/Activity.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivityService = void 0;
var Fetch_1 = require("./Fetch");
var Activity_1 = require("../model/Activity");
var Demo_1 = require("./Demo");
Expand Down
1 change: 1 addition & 0 deletions dist/service/ActivityEvent.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivityEventService = void 0;
var Fetch_1 = require("./Fetch");
var ActivityEvent_1 = require("../model/ActivityEvent");
var Demo_1 = require("./Demo");
Expand Down
1 change: 1 addition & 0 deletions dist/service/ActivitySpec.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivitySpecService = void 0;
var Fetch_1 = require("./Fetch");
var ActivitySpec_1 = require("../model/ActivitySpec");
var Demo_1 = require("./Demo");
Expand Down
21 changes: 21 additions & 0 deletions dist/service/Credential.service.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Identifier } from "../model/Type";
import { Credential } from "../model/Credential";
import { PersonalAccessToken } from "../model/PersonalAccessToken";
export declare class CredentialService {
/**
*
Expand All @@ -25,4 +26,24 @@ export declare class CredentialService {
* @param secretKey
*/
update(typeId: Identifier, accessKey: string, secretKey: string, description?: string): Promise<Identifier>;
/**
*
* @param accessKey
*/
listTokens(accessKey: string): Promise<PersonalAccessToken[]>;
/**
*
* @param accessKey
* @param expiry
* @param description
*/
createToken(accessKey: string, expiry: number, description: string): Promise<string | null>;
/**
*
* @param accessKey
* @param token
*/
deleteToken(accessKey: string, token: string): Promise<{
success: boolean;
}>;
}
73 changes: 73 additions & 0 deletions dist/service/Credential.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CredentialService = void 0;
var Fetch_1 = require("./Fetch");
var Credential_1 = require("../model/Credential");
var Demo_1 = require("./Demo");
var index_1 = __importDefault(require("../index"));
var jsonata_1 = __importDefault(require("jsonata"));
var PersonalAccessToken_1 = require("../model/PersonalAccessToken");
var CredentialService = /** @class */ (function () {
function CredentialService() {
}
Expand Down Expand Up @@ -224,6 +226,77 @@ var CredentialService = /** @class */ (function () {
});
});
};
/**
*
* @param accessKey
*/
CredentialService.prototype.listTokens = function (accessKey) {
return __awaiter(this, void 0, void 0, function () {
var tenDays;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (accessKey === null || accessKey === undefined)
throw new Error("Required parameter accessKey was null or undefined when calling credentialCreateToken.");
if (index_1.default.Auth._auth.serverAddress === "https://demo.lamp.digital") {
tenDays = 1000 * 3600 * 24 * 10;
return [2 /*return*/, [{ token: "qwertyuiop", expiry: Date.now() + tenDays, created: Date.now() - tenDays, description: "My Token" }]];
}
return [4 /*yield*/, Fetch_1.Fetch.get("/credential/" + accessKey + "/token")];
case 1: return [2 /*return*/, (_a.sent()).data.map(function (x) {
return Object.assign(new PersonalAccessToken_1.PersonalAccessToken(), x);
})];
}
});
});
};
/**
*
* @param accessKey
* @param expiry
* @param description
*/
CredentialService.prototype.createToken = function (accessKey, expiry, description) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (accessKey === null || accessKey === undefined)
throw new Error("Required parameter accessKey was null or undefined when calling credentialCreateToken.");
if (index_1.default.Auth._auth.serverAddress === "https://demo.lamp.digital") {
// DEMO
return [2 /*return*/, Promise.resolve({})];
}
return [4 /*yield*/, Fetch_1.Fetch.post("/credential/" + accessKey + "/token", { expiry: expiry, description: description })];
case 1: return [2 /*return*/, (_a.sent()).data];
}
});
});
};
/**
*
* @param accessKey
* @param token
*/
CredentialService.prototype.deleteToken = function (accessKey, token) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (accessKey === null || accessKey === undefined)
throw new Error("Required parameter accessKey was null or undefined when calling credentialDeleteToken.");
if (token === null || token === undefined)
throw new Error("Required parameter token was null or undefined when calling credentialDeleteToken.");
if (index_1.default.Auth._auth.serverAddress === "https://demo.lamp.digital") {
// DEMO
return [2 /*return*/, Promise.resolve({})];
}
return [4 /*yield*/, Fetch_1.Fetch.delete("/credential/" + accessKey + "/token/" + token)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return CredentialService;
}());
exports.CredentialService = CredentialService;
1 change: 1 addition & 0 deletions dist/service/Demo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Demo = void 0;
//
// [NOTE]: Demo mode carries various restrictions and does not:
// (1) verify R/W permissions.
Expand Down
1 change: 1 addition & 0 deletions dist/service/Fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Fetch = void 0;
var index_1 = __importDefault(require("../index"));
var await_semaphore_1 = require("await-semaphore");
var _tokenSemaphore = new await_semaphore_1.Semaphore(1);
Expand Down
1 change: 1 addition & 0 deletions dist/service/OAuth.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OAuthService = void 0;
var Fetch_1 = require("./Fetch");
var OAuthService = /** @class */ (function () {
function OAuthService() {
Expand Down
1 change: 1 addition & 0 deletions dist/service/Participant.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParticipantService = void 0;
var Fetch_1 = require("./Fetch");
var Participant_1 = require("../model/Participant");
var Demo_1 = require("./Demo");
Expand Down
Loading

0 comments on commit 16bfe75

Please sign in to comment.