@eazo/sdk 0.10.0 → 0.13.0
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/PROTOCOL.md +8 -1
- package/README.md +78 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/auth-primitive/EazoAuthClient.js +1 -1
- package/dist/internal/auth-primitive/EazoAuthClient.js.map +1 -1
- package/dist/internal/banner-ui/icons.d.ts +12 -0
- package/dist/internal/banner-ui/icons.d.ts.map +1 -0
- package/dist/internal/banner-ui/icons.js +12 -0
- package/dist/internal/banner-ui/icons.js.map +1 -0
- package/dist/internal/banner-ui/index.d.ts +8 -0
- package/dist/internal/banner-ui/index.d.ts.map +1 -0
- package/dist/internal/banner-ui/index.js +111 -0
- package/dist/internal/banner-ui/index.js.map +1 -0
- package/dist/internal/banner-ui/store-links.d.ts +5 -0
- package/dist/internal/banner-ui/store-links.d.ts.map +1 -0
- package/dist/internal/banner-ui/store-links.js +28 -0
- package/dist/internal/banner-ui/store-links.js.map +1 -0
- package/dist/internal/banner-ui/styles.d.ts +5 -0
- package/dist/internal/banner-ui/styles.d.ts.map +1 -0
- package/dist/internal/banner-ui/styles.js +122 -0
- package/dist/internal/banner-ui/styles.js.map +1 -0
- package/dist/internal/bridge/protocol.d.ts +7 -0
- package/dist/internal/bridge/protocol.d.ts.map +1 -1
- package/dist/internal/bridge/protocol.js +6 -1
- package/dist/internal/bridge/protocol.js.map +1 -1
- package/dist/internal/capabilities/ai.js +1 -1
- package/dist/internal/capabilities/ai.js.map +1 -1
- package/dist/internal/capabilities/auth.d.ts +10 -5
- package/dist/internal/capabilities/auth.d.ts.map +1 -1
- package/dist/internal/capabilities/auth.js +29 -13
- package/dist/internal/capabilities/auth.js.map +1 -1
- package/dist/internal/capabilities/device.d.ts +0 -1
- package/dist/internal/capabilities/device.d.ts.map +1 -1
- package/dist/internal/capabilities/device.js +2 -6
- package/dist/internal/capabilities/device.js.map +1 -1
- package/dist/internal/capabilities/memory.d.ts +10 -15
- package/dist/internal/capabilities/memory.d.ts.map +1 -1
- package/dist/internal/capabilities/memory.js +30 -21
- package/dist/internal/capabilities/memory.js.map +1 -1
- package/dist/internal/capabilities/notifications.d.ts +41 -0
- package/dist/internal/capabilities/notifications.d.ts.map +1 -0
- package/dist/internal/capabilities/notifications.js +61 -0
- package/dist/internal/capabilities/notifications.js.map +1 -0
- package/dist/internal/capabilities/share.d.ts +4 -2
- package/dist/internal/capabilities/share.d.ts.map +1 -1
- package/dist/internal/capabilities/share.js +13 -9
- package/dist/internal/capabilities/share.js.map +1 -1
- package/dist/internal/capabilities/storage.d.ts +7 -11
- package/dist/internal/capabilities/storage.d.ts.map +1 -1
- package/dist/internal/capabilities/storage.js +5 -13
- package/dist/internal/capabilities/storage.js.map +1 -1
- package/dist/internal/config.d.ts +9 -12
- package/dist/internal/config.d.ts.map +1 -1
- package/dist/internal/config.js +53 -22
- package/dist/internal/config.js.map +1 -1
- package/dist/internal/store.d.ts.map +1 -1
- package/dist/internal/store.js +0 -1
- package/dist/internal/store.js.map +1 -1
- package/dist/react.d.ts +9 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +14 -6
- package/dist/react.js.map +1 -1
- package/dist/server.d.ts +27 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +146 -0
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ const protocol_1 = require("../bridge/protocol");
|
|
|
9
9
|
const store_1 = require("../store");
|
|
10
10
|
const MAX_IMAGES = 4;
|
|
11
11
|
function getShareDownloadUrl() {
|
|
12
|
-
return `${(0, config_1.
|
|
12
|
+
return `${(0, config_1.getPlatformApiBase)()}/`;
|
|
13
13
|
}
|
|
14
14
|
function __resetShareCapability() {
|
|
15
15
|
(0, store_1.setShareUI)({ open: false });
|
|
@@ -65,6 +65,13 @@ exports.share = {
|
|
|
65
65
|
async compose(input) {
|
|
66
66
|
validate(input);
|
|
67
67
|
const payload = normalize(input);
|
|
68
|
+
// Auto-stamp the running app's id when the caller didn't supply an
|
|
69
|
+
// explicit override. Mirrors the same default applied in `memory`.
|
|
70
|
+
if (!payload.sourceAppId) {
|
|
71
|
+
const appId = (0, config_1.getAppId)();
|
|
72
|
+
if (appId)
|
|
73
|
+
payload.sourceAppId = appId;
|
|
74
|
+
}
|
|
68
75
|
const hello = await (0, bootstrap_1.waitForBootstrap)();
|
|
69
76
|
const bridge = (0, bootstrap_1.getBridge)();
|
|
70
77
|
if (hello && bridge?.getStatus().ready) {
|
|
@@ -75,17 +82,14 @@ exports.share = {
|
|
|
75
82
|
return { accepted: result?.accepted ?? true };
|
|
76
83
|
}
|
|
77
84
|
catch (err) {
|
|
78
|
-
|
|
79
|
-
(err.code === "NOT_SUPPORTED" || err.code === "TIMEOUT")
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
85
|
+
const fallbackable = err instanceof protocol_1.BridgeErrorObject &&
|
|
86
|
+
(err.code === "NOT_SUPPORTED" || err.code === "TIMEOUT");
|
|
87
|
+
if (!fallbackable)
|
|
83
88
|
throw err;
|
|
84
|
-
|
|
89
|
+
// fall through to web fallback
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
|
-
//
|
|
88
|
-
// effectful but predictable — apps can detect it via `accepted: false`.
|
|
92
|
+
// Side-effectful but observable: apps detect this branch via `accepted: false`.
|
|
89
93
|
if (typeof document !== "undefined") {
|
|
90
94
|
(0, store_1.setShareUI)({ open: true });
|
|
91
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share.js","sourceRoot":"","sources":["../../../src/internal/capabilities/share.ts"],"names":[],"mappings":";;;AAMA,kDAEC;
|
|
1
|
+
{"version":3,"file":"share.js","sourceRoot":"","sources":["../../../src/internal/capabilities/share.ts"],"names":[],"mappings":";;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,CAAC;QACzC,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAA,4BAAgB,GAAE,CAAC;QACvC,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;QAE3B,IAAI,KAAK,IAAI,MAAM,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAqB,wBAAa,EAAE,OAAO,CAAC,CAAC;gBAChF,mEAAmE;gBACnE,+CAA+C;gBAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAC;YAChD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,YAAY,GAChB,GAAG,YAAY,4BAAiB;oBAChC,CAAC,GAAG,CAAC,IAAI,KAAK,eAAe,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;gBAC3D,IAAI,CAAC,YAAY;oBAAE,MAAM,GAAG,CAAC;gBAC7B,+BAA+B;YACjC,CAAC;QACH,CAAC;QAED,gFAAgF;QAChF,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACpC,IAAA,kBAAU,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF,CAAC"}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
export interface StorageCredentials {
|
|
2
|
-
/** Presigned PUT URL —
|
|
2
|
+
/** Presigned PUT URL — issue the request without an auth header. */
|
|
3
3
|
uploadUrl: string;
|
|
4
|
-
/**
|
|
4
|
+
/** Permanent CDN URL for the uploaded object (no expiry). */
|
|
5
5
|
publicUrl: string;
|
|
6
|
-
/** Full S3 object key
|
|
6
|
+
/** Full S3 object key, e.g. `app-contents/{md5(ownerId)}/{path}`. */
|
|
7
7
|
key: string;
|
|
8
8
|
bucket: string;
|
|
9
9
|
region: string;
|
|
10
|
-
/** ISO timestamp
|
|
10
|
+
/** ISO timestamp at which `uploadUrl` expires. */
|
|
11
11
|
expiration: string;
|
|
12
12
|
}
|
|
13
13
|
export interface UploadResult {
|
|
14
|
-
/** Full S3 object key */
|
|
15
14
|
key: string;
|
|
16
|
-
/** Publicly accessible CDN URL */
|
|
17
15
|
url: string;
|
|
18
16
|
}
|
|
19
17
|
export declare const storage: {
|
|
20
18
|
/**
|
|
21
19
|
* Upload a file to Eazo built-in object storage.
|
|
22
20
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* 2. PUTs the file directly to S3 — no platform bandwidth used.
|
|
27
|
-
* 3. Returns the S3 key and a permanent CDN URL.
|
|
21
|
+
* Two-step: requests a presigned PUT URL (tenant-scoped via STS Session
|
|
22
|
+
* Policy), then PUTs directly to S3 — no platform bandwidth in the
|
|
23
|
+
* critical path. Returns the S3 key and a permanent CDN URL.
|
|
28
24
|
*
|
|
29
25
|
* @param path Relative object path, e.g. "todos/123/avatar.png"
|
|
30
26
|
* @param file File or Blob to upload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AA6BD,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;OAUG;iBAEK,MAAM,QACN,IAAI,GAAG,IAAI,YACR;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAChC,OAAO,CAAC,YAAY,CAAC;IAiBxB;;;;OAIG;yBACkB,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAG1D,CAAC"}
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.storage = void 0;
|
|
4
4
|
const config_1 = require("../config");
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// Internal helpers
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
5
|
async function fetchCredentials(path) {
|
|
9
6
|
const appId = (0, config_1.getAppId)();
|
|
10
7
|
if (!appId) {
|
|
11
|
-
throw new Error("@eazo/sdk:
|
|
8
|
+
throw new Error("@eazo/sdk: app id not configured. Mount <EazoProvider appId={...}> at the root of your app.");
|
|
12
9
|
}
|
|
13
|
-
const res = await fetch(`${(0, config_1.
|
|
10
|
+
const res = await fetch(`${(0, config_1.getPlatformApiBase)()}/api/open/storage-credentials`, {
|
|
14
11
|
method: "POST",
|
|
15
12
|
headers: { "Content-Type": "application/json" },
|
|
16
13
|
body: JSON.stringify({ appId, path }),
|
|
@@ -28,18 +25,13 @@ async function fetchCredentials(path) {
|
|
|
28
25
|
const json = await res.json();
|
|
29
26
|
return json.data;
|
|
30
27
|
}
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
// Public API
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
28
|
exports.storage = {
|
|
35
29
|
/**
|
|
36
30
|
* Upload a file to Eazo built-in object storage.
|
|
37
31
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* 2. PUTs the file directly to S3 — no platform bandwidth used.
|
|
42
|
-
* 3. Returns the S3 key and a permanent CDN URL.
|
|
32
|
+
* Two-step: requests a presigned PUT URL (tenant-scoped via STS Session
|
|
33
|
+
* Policy), then PUTs directly to S3 — no platform bandwidth in the
|
|
34
|
+
* critical path. Returns the S3 key and a permanent CDN URL.
|
|
43
35
|
*
|
|
44
36
|
* @param path Relative object path, e.g. "todos/123/avatar.png"
|
|
45
37
|
* @param file File or Blob to upload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":";;;AAAA,sCAAyD;AAoBzD,KAAK,UAAU,gBAAgB,CAAC,IAAY;IAC1C,MAAM,KAAK,GAAG,IAAA,iBAAQ,GAAE,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAA,2BAAkB,GAAE,+BAA+B,EAAE;QAC9E,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;KACtC,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,IAAI,OAAO,GAAG,sCAAsC,GAAG,CAAC,MAAM,EAAE,CAAC;QACjE,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAA0B,CAAC;YACtD,IAAI,IAAI,EAAE,OAAO;gBAAE,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5C,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAkC,CAAC;IAC9D,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAEY,QAAA,OAAO,GAAG;IACrB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,MAAM,CACV,IAAY,EACZ,IAAiB,EACjB,UAAoC,EAAE;QAEtC,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,IAAI,YAAY,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC;QAE3G,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE;YAC1C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;SACzC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,IAAY;QACzB,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF,CAAC"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared runtime configuration
|
|
3
|
-
*
|
|
2
|
+
* Shared runtime configuration. Dependency-free so both bootstrap and
|
|
3
|
+
* capability modules can read/write without circular imports.
|
|
4
4
|
*/
|
|
5
|
+
export declare const DEFAULT_PLATFORM_API_BASE = "https://eazo.ai";
|
|
6
|
+
/** Set by `<EazoProvider appId={...}>`. */
|
|
5
7
|
export declare function setAppId(id: string | null): void;
|
|
6
|
-
/**
|
|
7
|
-
* Returns the configured Eazo app ID. Falls back to
|
|
8
|
-
* NEXT_PUBLIC_EAZO_APP_ID when no explicit override has been set via
|
|
9
|
-
* `auth.configure({ appId })`.
|
|
10
|
-
*/
|
|
8
|
+
/** Explicit value via setAppId, then env-name list, then null. */
|
|
11
9
|
export declare function getAppId(): string | null;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export declare function getApiBase(override?: string): string;
|
|
10
|
+
/** Set from `hello.apiBase` during device-capability bootstrap. */
|
|
11
|
+
export declare function setHostApiBase(url: string | null): void;
|
|
12
|
+
export declare function getPlatformApiBase(override?: string): string;
|
|
13
|
+
export declare function readAppIdFromEnv(): string | null;
|
|
17
14
|
export declare function __resetConfig(): void;
|
|
18
15
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEhD;AAED
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AA8B3D,2CAA2C;AAC3C,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEhD;AAED,kEAAkE;AAClE,wBAAgB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAGxC;AAED,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEvD;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAM5D;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEhD;AAED,wBAAgB,aAAa,IAAI,IAAI,CAGpC"}
|
package/dist/internal/config.js
CHANGED
|
@@ -1,44 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Shared runtime configuration
|
|
4
|
-
*
|
|
3
|
+
* Shared runtime configuration. Dependency-free so both bootstrap and
|
|
4
|
+
* capability modules can read/write without circular imports.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DEFAULT_PLATFORM_API_BASE = void 0;
|
|
7
8
|
exports.setAppId = setAppId;
|
|
8
9
|
exports.getAppId = getAppId;
|
|
9
|
-
exports.
|
|
10
|
+
exports.setHostApiBase = setHostApiBase;
|
|
11
|
+
exports.getPlatformApiBase = getPlatformApiBase;
|
|
12
|
+
exports.readAppIdFromEnv = readAppIdFromEnv;
|
|
10
13
|
exports.__resetConfig = __resetConfig;
|
|
11
14
|
let appId = null;
|
|
12
|
-
|
|
15
|
+
let hostInjectedApiBase = null;
|
|
16
|
+
exports.DEFAULT_PLATFORM_API_BASE = "https://eazo.ai";
|
|
17
|
+
function readEnvByNames(names) {
|
|
18
|
+
if (typeof process === "undefined" || !process.env)
|
|
19
|
+
return null;
|
|
20
|
+
for (const name of names) {
|
|
21
|
+
const value = process.env[name];
|
|
22
|
+
if (typeof value === "string" && value.length > 0)
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const APP_ID_ENV_NAMES = [
|
|
28
|
+
"EAZO_APP_ID",
|
|
29
|
+
"NEXT_PUBLIC_EAZO_APP_ID",
|
|
30
|
+
"EXPO_PUBLIC_EAZO_APP_ID",
|
|
31
|
+
"VITE_EAZO_APP_ID",
|
|
32
|
+
"PUBLIC_EAZO_APP_ID",
|
|
33
|
+
"REACT_APP_EAZO_APP_ID",
|
|
34
|
+
];
|
|
35
|
+
const API_BASE_ENV_NAMES = [
|
|
36
|
+
"EAZO_API_BASE",
|
|
37
|
+
"EAZO_API_URL",
|
|
38
|
+
"NEXT_PUBLIC_EAZO_API_URL",
|
|
39
|
+
"EXPO_PUBLIC_EAZO_API_URL",
|
|
40
|
+
"VITE_EAZO_API_URL",
|
|
41
|
+
"PUBLIC_EAZO_API_URL",
|
|
42
|
+
"REACT_APP_EAZO_API_URL",
|
|
43
|
+
];
|
|
44
|
+
/** Set by `<EazoProvider appId={...}>`. */
|
|
13
45
|
function setAppId(id) {
|
|
14
46
|
appId = id;
|
|
15
47
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Returns the configured Eazo app ID. Falls back to
|
|
18
|
-
* NEXT_PUBLIC_EAZO_APP_ID when no explicit override has been set via
|
|
19
|
-
* `auth.configure({ appId })`.
|
|
20
|
-
*/
|
|
48
|
+
/** Explicit value via setAppId, then env-name list, then null. */
|
|
21
49
|
function getAppId() {
|
|
22
50
|
if (appId)
|
|
23
51
|
return appId;
|
|
24
|
-
|
|
25
|
-
return process.env.NEXT_PUBLIC_EAZO_APP_ID;
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
52
|
+
return readEnvByNames(APP_ID_ENV_NAMES);
|
|
28
53
|
}
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function
|
|
54
|
+
/** Set from `hello.apiBase` during device-capability bootstrap. */
|
|
55
|
+
function setHostApiBase(url) {
|
|
56
|
+
hostInjectedApiBase = url ? url.replace(/\/$/, "") : null;
|
|
57
|
+
}
|
|
58
|
+
function getPlatformApiBase(override) {
|
|
34
59
|
if (override)
|
|
35
60
|
return override.replace(/\/$/, "");
|
|
36
|
-
if (
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
61
|
+
if (hostInjectedApiBase)
|
|
62
|
+
return hostInjectedApiBase;
|
|
63
|
+
const fromEnv = readEnvByNames(API_BASE_ENV_NAMES);
|
|
64
|
+
if (fromEnv)
|
|
65
|
+
return fromEnv.replace(/\/$/, "");
|
|
66
|
+
return exports.DEFAULT_PLATFORM_API_BASE;
|
|
67
|
+
}
|
|
68
|
+
function readAppIdFromEnv() {
|
|
69
|
+
return readEnvByNames(APP_ID_ENV_NAMES);
|
|
40
70
|
}
|
|
41
71
|
function __resetConfig() {
|
|
42
72
|
appId = null;
|
|
73
|
+
hostInjectedApiBase = null;
|
|
43
74
|
}
|
|
44
75
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoCH,4BAEC;AAGD,4BAGC;AAGD,wCAEC;AAED,gDAMC;AAED,4CAEC;AAED,sCAGC;AAhED,IAAI,KAAK,GAAkB,IAAI,CAAC;AAChC,IAAI,mBAAmB,GAAkB,IAAI,CAAC;AAEjC,QAAA,yBAAyB,GAAG,iBAAiB,CAAC;AAE3D,SAAS,cAAc,CAAC,KAAwB;IAC9C,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IAChE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IAClE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,gBAAgB,GAAG;IACvB,aAAa;IACb,yBAAyB;IACzB,yBAAyB;IACzB,kBAAkB;IAClB,oBAAoB;IACpB,uBAAuB;CACf,CAAC;AAEX,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AS;IAClD,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,EAAE,iBAK3B,CAAC;AAKF,eAAO,MAAM,KAAK;mBACD,iBAAiB;yBAGX,iBAAiB;wBAGlB,QAAQ,GAAG,MAAM,IAAI;aAIhC,IAAI;CAId,CAAC;AAOF,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAWvD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAQ7D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAQ7D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAQ7D"}
|
package/dist/internal/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/internal/store.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/internal/store.ts"],"names":[],"mappings":";;;AAqFA,0BAWC;AAED,8BAQC;AAED,gCAQC;AAED,gCAQC;AA3GD,MAAM,YAAY,GAAc;IAC9B,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,KAAK;CACrB,CAAC;AAEF,MAAM,cAAc,GAAkB;IACpC,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,OAAO;CAChB,CAAC;AAEF,MAAM,gBAAgB,GAAiB;IACrC,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,WAAW;IACjB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,EAAE;IACb,gBAAgB,EAAE,KAAK;IACvB,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,KAAK;CAClB,CAAC;AAMF,MAAM,gBAAgB,GAAiB;IAC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C,GAAG,CAAC,CACpC,CAAC;IACF,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,OAAO,CAAC,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/react.d.ts
CHANGED
|
@@ -3,19 +3,23 @@ import type { EazoState } from "./types";
|
|
|
3
3
|
/**
|
|
4
4
|
* Mounts the SDK runtime. Place once at the root of your React tree.
|
|
5
5
|
*
|
|
6
|
-
* <EazoProvider>
|
|
6
|
+
* <EazoProvider appId={process.env.EAZO_APP_ID}>
|
|
7
7
|
* <App />
|
|
8
8
|
* </EazoProvider>
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* `<EazoProvider>` is how an app's appId reaches every SDK capability
|
|
11
|
+
* (`auth`, `device`, `share`, `storage`, `memory`); every project must
|
|
12
|
+
* pass one. Also mounts the shared login and share UIs so `auth.login()`
|
|
13
|
+
* and `share.compose()` work anywhere in the tree.
|
|
12
14
|
*/
|
|
13
15
|
export declare function EazoProvider(props: {
|
|
14
16
|
children: React.ReactNode;
|
|
17
|
+
/** Eazo app ID. Required. */
|
|
18
|
+
appId: string;
|
|
15
19
|
}): React.ReactElement;
|
|
16
20
|
/**
|
|
17
|
-
* Subscribe to a slice of
|
|
18
|
-
*
|
|
21
|
+
* Subscribe to a slice of state. Re-renders only when the selector's
|
|
22
|
+
* return value changes (Object.is).
|
|
19
23
|
*
|
|
20
24
|
* const user = useEazo(s => s.auth.user);
|
|
21
25
|
* const { platform, locale } = useEazo(s => s.device);
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIzC;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,KAAK,CAAC,YAAY,CAuBrB;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,CAkB/D"}
|
package/dist/react.js
CHANGED
|
@@ -37,9 +37,11 @@ exports.EazoProvider = EazoProvider;
|
|
|
37
37
|
exports.useEazo = useEazo;
|
|
38
38
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
39
|
const React = __importStar(require("react"));
|
|
40
|
+
const banner_ui_1 = require("./internal/banner-ui");
|
|
40
41
|
const bootstrap_1 = require("./internal/bootstrap");
|
|
41
42
|
const auth_1 = require("./internal/capabilities/auth");
|
|
42
43
|
const device_1 = require("./internal/capabilities/device");
|
|
44
|
+
const config_1 = require("./internal/config");
|
|
43
45
|
const login_ui_1 = require("./internal/login-ui");
|
|
44
46
|
const share_ui_1 = require("./internal/share-ui");
|
|
45
47
|
const store_1 = require("./internal/store");
|
|
@@ -47,25 +49,31 @@ const MountedContext = React.createContext(false);
|
|
|
47
49
|
/**
|
|
48
50
|
* Mounts the SDK runtime. Place once at the root of your React tree.
|
|
49
51
|
*
|
|
50
|
-
* <EazoProvider>
|
|
52
|
+
* <EazoProvider appId={process.env.EAZO_APP_ID}>
|
|
51
53
|
* <App />
|
|
52
54
|
* </EazoProvider>
|
|
53
55
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
+
* `<EazoProvider>` is how an app's appId reaches every SDK capability
|
|
57
|
+
* (`auth`, `device`, `share`, `storage`, `memory`); every project must
|
|
58
|
+
* pass one. Also mounts the shared login and share UIs so `auth.login()`
|
|
59
|
+
* and `share.compose()` work anywhere in the tree.
|
|
56
60
|
*/
|
|
57
61
|
function EazoProvider(props) {
|
|
62
|
+
if (!props.appId) {
|
|
63
|
+
throw new Error("@eazo/sdk: <EazoProvider appId> is required. Pass your Eazo app id explicitly.");
|
|
64
|
+
}
|
|
65
|
+
(0, config_1.setAppId)(props.appId);
|
|
58
66
|
React.useEffect(() => {
|
|
59
67
|
// Starting the bridge is idempotent; capability access may have already done so.
|
|
60
68
|
(0, bootstrap_1.getBridge)();
|
|
61
69
|
void (0, auth_1._bootstrapAuth)();
|
|
62
70
|
void (0, device_1._bootstrapDevice)();
|
|
63
71
|
}, []);
|
|
64
|
-
return ((0, jsx_runtime_1.jsxs)(MountedContext.Provider, { value: true, children: [props.children, (0, jsx_runtime_1.jsx)(login_ui_1.LoginUI, {}), (0, jsx_runtime_1.jsx)(share_ui_1.ShareDownloadModal, {})] }));
|
|
72
|
+
return ((0, jsx_runtime_1.jsxs)(MountedContext.Provider, { value: true, children: [props.children, (0, jsx_runtime_1.jsx)(banner_ui_1.EazoBrandBanner, {}), (0, jsx_runtime_1.jsx)(login_ui_1.LoginUI, {}), (0, jsx_runtime_1.jsx)(share_ui_1.ShareDownloadModal, {})] }));
|
|
65
73
|
}
|
|
66
74
|
/**
|
|
67
|
-
* Subscribe to a slice of
|
|
68
|
-
*
|
|
75
|
+
* Subscribe to a slice of state. Re-renders only when the selector's
|
|
76
|
+
* return value changes (Object.is).
|
|
69
77
|
*
|
|
70
78
|
* const user = useEazo(s => s.auth.user);
|
|
71
79
|
* const { platform, locale } = useEazo(s => s.device);
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"react.js","sourceRo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AG,KAAK,CAAC,WAAW,CACnC,GAAG,EAAE,CAAC,QAAQ,CAAC,aAAK,CAAC,WAAW,EAAE,CAAC,EACnC,CAAC,QAAQ,CAAC,CACX,CAAC;IACF,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,GAAG,EAAE,CAAC,QAAQ,CAAC,qBAAa,CAAC,EAC7B,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,KAAK,CAAC,oBAAoB,CAAC,aAAK,CAAC,SAAS,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;AACrF,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -17,5 +17,32 @@ export type AuthResult = {
|
|
|
17
17
|
* encrypted session with EAZO_PRIVATE_KEY, and returns the user.
|
|
18
18
|
*/
|
|
19
19
|
export declare function requireAuth(request: HeaderRequest): AuthResult;
|
|
20
|
+
export declare class EazoNotificationPublishError extends Error {
|
|
21
|
+
readonly code: number;
|
|
22
|
+
readonly publishId?: string;
|
|
23
|
+
constructor(message: string, code: number, publishId?: string);
|
|
24
|
+
}
|
|
25
|
+
export interface NotificationPublishInput {
|
|
26
|
+
/** Title shown in the system push tray. Up to 120 chars. */
|
|
27
|
+
title: string;
|
|
28
|
+
/** Body of the notification. Up to 500 chars. */
|
|
29
|
+
body: string;
|
|
30
|
+
/** Optional structured payload merged into the device-side `data`. */
|
|
31
|
+
data?: Record<string, unknown>;
|
|
32
|
+
/** v1 only supports `subscribers`; future values may include explicit user lists. */
|
|
33
|
+
audience?: "subscribers";
|
|
34
|
+
}
|
|
35
|
+
export interface NotificationPublishResult {
|
|
36
|
+
delivered: number;
|
|
37
|
+
publishId: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Server-side publish to subscribers of this app. Signs a JWT with
|
|
41
|
+
* `EAZO_PRIVATE_KEY` and POSTs to the platform; throws
|
|
42
|
+
* `EazoNotificationPublishError` on non-zero response codes.
|
|
43
|
+
*/
|
|
44
|
+
export declare const notifications: {
|
|
45
|
+
publish(input: NotificationPublishInput): Promise<NotificationPublishResult>;
|
|
46
|
+
};
|
|
20
47
|
export type { User } from "./types";
|
|
21
48
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAyBpC,uEAAuE;AACvE,UAAU,aAAa;IACrB,OAAO,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CAC/C;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GACxB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC;AAStC;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,UAAU,CAiB9D;AAWD,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;gBAChB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAM9D;AA6CD,MAAM,WAAW,wBAAwB;IACvC,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,qFAAqF;IACrF,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa;mBACH,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAoEnF,CAAC;AAEF,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.notifications = exports.EazoNotificationPublishError = void 0;
|
|
3
37
|
exports.requireAuth = requireAuth;
|
|
38
|
+
const crypto = __importStar(require("crypto"));
|
|
39
|
+
const elliptic_1 = require("elliptic");
|
|
4
40
|
const auth_primitive_1 = require("./internal/auth-primitive");
|
|
41
|
+
const config_1 = require("./internal/config");
|
|
5
42
|
let authServer = null;
|
|
6
43
|
function getAuthServer() {
|
|
7
44
|
if (authServer)
|
|
@@ -50,4 +87,113 @@ function requireAuth(request) {
|
|
|
50
87
|
return { ok: false, response: unauthorized("Invalid session") };
|
|
51
88
|
}
|
|
52
89
|
}
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// notifications.publish — server-to-server push to subscribers of an Eazo app
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
const NOTIFICATIONS_PUBLISH_AUDIENCE = "eazo.notifications.publish";
|
|
94
|
+
const NOTIFICATIONS_PUBLISH_TTL_SECONDS = 60;
|
|
95
|
+
const ec = new elliptic_1.ec("secp256k1");
|
|
96
|
+
class EazoNotificationPublishError extends Error {
|
|
97
|
+
constructor(message, code, publishId) {
|
|
98
|
+
super(message);
|
|
99
|
+
this.name = "EazoNotificationPublishError";
|
|
100
|
+
this.code = code;
|
|
101
|
+
this.publishId = publishId;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.EazoNotificationPublishError = EazoNotificationPublishError;
|
|
105
|
+
function base64urlEncode(buf) {
|
|
106
|
+
const b = typeof buf === "string" ? Buffer.from(buf, "utf8") : buf;
|
|
107
|
+
return b.toString("base64").replace(/=+$/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
108
|
+
}
|
|
109
|
+
/** Sign an ES256K JWT (header.payload.signature with raw r||s signature). */
|
|
110
|
+
function signES256K(privateKeyHex, payload) {
|
|
111
|
+
const header = { alg: "ES256K", typ: "JWT" };
|
|
112
|
+
const encodedHeader = base64urlEncode(JSON.stringify(header));
|
|
113
|
+
const encodedPayload = base64urlEncode(JSON.stringify(payload));
|
|
114
|
+
const signingInput = `${encodedHeader}.${encodedPayload}`;
|
|
115
|
+
const digest = crypto.createHash("sha256").update(signingInput).digest();
|
|
116
|
+
const keyPair = ec.keyFromPrivate(privateKeyHex, "hex");
|
|
117
|
+
const sig = keyPair.sign(digest, { canonical: true });
|
|
118
|
+
const r = sig.r.toString(16).padStart(64, "0");
|
|
119
|
+
const s = sig.s.toString(16).padStart(64, "0");
|
|
120
|
+
const sigBytes = Buffer.from(r + s, "hex");
|
|
121
|
+
return `${signingInput}.${base64urlEncode(sigBytes)}`;
|
|
122
|
+
}
|
|
123
|
+
function getDeveloperPrivateKey() {
|
|
124
|
+
const privateKey = process.env.EAZO_PRIVATE_KEY;
|
|
125
|
+
if (!privateKey) {
|
|
126
|
+
throw new Error("@eazo/sdk/server: EAZO_PRIVATE_KEY is required for notifications.publish().");
|
|
127
|
+
}
|
|
128
|
+
return privateKey;
|
|
129
|
+
}
|
|
130
|
+
function derivePublicKey(privateKeyHex) {
|
|
131
|
+
return ec.keyFromPrivate(privateKeyHex, "hex").getPublic(true, "hex");
|
|
132
|
+
}
|
|
133
|
+
function getDeveloperAppId() {
|
|
134
|
+
const fromEnv = (0, config_1.readAppIdFromEnv)();
|
|
135
|
+
if (!fromEnv) {
|
|
136
|
+
throw new Error("@eazo/sdk/server: EAZO_APP_ID is required for notifications.publish().");
|
|
137
|
+
}
|
|
138
|
+
return fromEnv;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Server-side publish to subscribers of this app. Signs a JWT with
|
|
142
|
+
* `EAZO_PRIVATE_KEY` and POSTs to the platform; throws
|
|
143
|
+
* `EazoNotificationPublishError` on non-zero response codes.
|
|
144
|
+
*/
|
|
145
|
+
exports.notifications = {
|
|
146
|
+
async publish(input) {
|
|
147
|
+
if (!input || typeof input !== "object") {
|
|
148
|
+
throw new Error("notifications.publish requires an input object");
|
|
149
|
+
}
|
|
150
|
+
if (!input.title)
|
|
151
|
+
throw new Error("notifications.publish: `title` is required");
|
|
152
|
+
if (!input.body)
|
|
153
|
+
throw new Error("notifications.publish: `body` is required");
|
|
154
|
+
const appId = getDeveloperAppId();
|
|
155
|
+
const privateKeyHex = getDeveloperPrivateKey();
|
|
156
|
+
const publicKeyHex = derivePublicKey(privateKeyHex);
|
|
157
|
+
const now = Math.floor(Date.now() / 1000);
|
|
158
|
+
const jwt = signES256K(privateKeyHex, {
|
|
159
|
+
iss: publicKeyHex,
|
|
160
|
+
aud: NOTIFICATIONS_PUBLISH_AUDIENCE,
|
|
161
|
+
iat: now,
|
|
162
|
+
exp: now + NOTIFICATIONS_PUBLISH_TTL_SECONDS,
|
|
163
|
+
jti: crypto.randomUUID(),
|
|
164
|
+
});
|
|
165
|
+
const url = `${(0, config_1.getPlatformApiBase)()}/api/open/notifications/publish`;
|
|
166
|
+
const res = await fetch(url, {
|
|
167
|
+
method: "POST",
|
|
168
|
+
headers: {
|
|
169
|
+
"Content-Type": "application/json",
|
|
170
|
+
Authorization: `Bearer ${jwt}`,
|
|
171
|
+
},
|
|
172
|
+
body: JSON.stringify({
|
|
173
|
+
appId,
|
|
174
|
+
title: input.title,
|
|
175
|
+
body: input.body,
|
|
176
|
+
data: input.data,
|
|
177
|
+
audience: input.audience ?? "subscribers",
|
|
178
|
+
}),
|
|
179
|
+
});
|
|
180
|
+
let json = null;
|
|
181
|
+
try {
|
|
182
|
+
json = (await res.json());
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
// Fall through to an HTTP-status-based error.
|
|
186
|
+
}
|
|
187
|
+
if (!json || typeof json.code !== "number") {
|
|
188
|
+
throw new EazoNotificationPublishError(`Unexpected response from notifications.publish (HTTP ${res.status})`, res.status);
|
|
189
|
+
}
|
|
190
|
+
if (json.code !== 0) {
|
|
191
|
+
throw new EazoNotificationPublishError(json.message ?? "publish failed", json.code, json.data?.publishId);
|
|
192
|
+
}
|
|
193
|
+
if (!json.data) {
|
|
194
|
+
throw new EazoNotificationPublishError("publish succeeded but response is missing data", 500);
|
|
195
|
+
}
|
|
196
|
+
return json.data;
|
|
197
|
+
},
|
|
198
|
+
};
|
|
53
199
|
//# sourceMappingURL=server.js.map
|