@blueprint-sdk/app
Advanced tools
Comparing version 0.1.2 to 0.1.3
# @blueprint-sdk/app | ||
## 0.1.3 | ||
### Patch Changes | ||
- 2efe72a1: Add support for external media ID | ||
## 0.1.2 | ||
@@ -4,0 +10,0 @@ |
var __defProp = Object.defineProperty; | ||
var __typeError = (msg) => { | ||
throw TypeError(msg); | ||
}; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); | ||
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); | ||
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); | ||
/** | ||
@@ -26,13 +20,12 @@ * @license | ||
*/ | ||
var _keyPayload; | ||
function getApiUrl(env) { | ||
switch (env) { | ||
case "dev": | ||
return "https://api2-dev.sourcesync.io"; | ||
return "https://platform-dev.sourcesync.io"; | ||
case "stg": | ||
return "https://api2-stg.sourcesync.io"; | ||
return "https://platform-stg.sourcesync.io"; | ||
case "prod": | ||
return "https://api2.sourcesync.io"; | ||
return "https://platform.sourcesync.io"; | ||
default: | ||
return "https://api2.sourcesync.io"; | ||
return "https://platform.sourcesync.io"; | ||
} | ||
@@ -49,3 +42,4 @@ } | ||
__publicField(this, "env"); | ||
__privateAdd(this, _keyPayload); | ||
__publicField(this, "verified", false); | ||
__publicField(this, "keyPayload"); | ||
this.options = options; | ||
@@ -55,2 +49,5 @@ this.env = options.env ?? "prod"; | ||
async verifyAppKey() { | ||
if (this.verified) { | ||
return; | ||
} | ||
const options = this.options; | ||
@@ -62,3 +59,3 @@ if (options.appKey == null) { | ||
getApiUrl(this.env) + "/key", | ||
{ method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ key: options.appKey }) } | ||
{ method: "GET", headers: { "Content-Type": "application/json", "X-API-Key": options.appKey } } | ||
); | ||
@@ -69,6 +66,13 @@ if (!result.ok) { | ||
} | ||
__privateSet(this, _keyPayload, await result.json()); | ||
this.keyPayload = await result.json(); | ||
this.verified = true; | ||
} | ||
get groupIdentifier() { | ||
var _a, _b; | ||
return { | ||
organizationId: this.keyPayload.organizationId ?? ((_a = this.keyPayload) == null ? void 0 : _a.organization_id), | ||
legacyOrganizationId: this.keyPayload.legacyOrganizationId ?? ((_b = this.keyPayload) == null ? void 0 : _b.legacy_org_id) | ||
}; | ||
} | ||
} | ||
_keyPayload = new WeakMap(); | ||
export { | ||
@@ -75,0 +79,0 @@ BluePrintAppImpl, |
@@ -0,1 +1,9 @@ | ||
/** | ||
* Information about the group(ex: org) that the app is associated with. | ||
*/ | ||
export declare interface AppGroupIdentifier { | ||
organizationId?: string; | ||
legacyOrganizationId?: string; | ||
} | ||
export declare interface BluePrintApp { | ||
@@ -5,10 +13,13 @@ options: BluePrintAppOptions; | ||
verifyAppKey: () => Promise<void>; | ||
groupIdentifier?: AppGroupIdentifier; | ||
} | ||
export declare class BluePrintAppImpl implements BluePrintApp { | ||
#private; | ||
options: BluePrintAppOptions; | ||
readonly env: string; | ||
private verified; | ||
private keyPayload; | ||
constructor(options: BluePrintAppOptions); | ||
verifyAppKey(): Promise<void>; | ||
get groupIdentifier(): AppGroupIdentifier | undefined; | ||
} | ||
@@ -15,0 +26,0 @@ |
{ | ||
"name": "@blueprint-sdk/app", | ||
"private": false, | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"type": "module", | ||
@@ -38,3 +38,3 @@ "author": "Source Digital <dev@sourcedigital.net>", | ||
"vitest": "^2.0.3", | ||
"@source-digital/experience-utils": "^0.4.3" | ||
"@source-digital/experience-utils": "^0.5.2" | ||
}, | ||
@@ -41,0 +41,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28958
202