buckyos 0.7.119 → 0.7.121
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/cli/README.md +24 -3
- package/cli/core/app.ts +28 -0
- package/cli/deno.json +2 -1
- package/cli/dist/cli.mjs +777 -169
- package/cli/dist/cli.mjs.map +1 -1
- package/cli/modules/app.ts +213 -94
- package/cli/modules/provision.ts +690 -0
- package/cli/runtime/host.ts +25 -2
- package/cli/runtime/host_deno.ts +4 -0
- package/cli/runtime/host_node.ts +4 -0
- package/cli/version.ts +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.mjs +124 -124
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +124 -124
- package/dist/{ndm_proxy-c00bc561.mjs → ndm_proxy-8f547002.mjs} +113 -216
- package/dist/ndm_proxy-8f547002.mjs.map +1 -0
- package/dist/ndm_proxy-93a8869b.js +13 -0
- package/dist/ndm_proxy-93a8869b.js.map +1 -0
- package/dist/ndn_types-44c69036.js +2 -0
- package/dist/ndn_types-44c69036.js.map +1 -0
- package/dist/{ndn_types-f6c08d20.mjs → ndn_types-d768245f.mjs} +149 -39
- package/dist/ndn_types-d768245f.mjs.map +1 -0
- package/dist/node.cjs +1 -1
- package/dist/node.mjs +124 -124
- package/dist/provision.cjs +6 -6
- package/dist/provision.cjs.map +1 -1
- package/dist/provision.d.ts +2 -0
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.mjs +1084 -35
- package/dist/provision.mjs.map +1 -1
- package/dist/provision_activate.d.ts +146 -0
- package/dist/provision_activate.d.ts.map +1 -0
- package/dist/{tus_client-573066b3.mjs → tus_client-b1c35e8c.mjs} +2 -2
- package/dist/{tus_client-573066b3.mjs.map → tus_client-b1c35e8c.mjs.map} +1 -1
- package/dist/{tus_client-83ad0f4f.js → tus_client-d0798623.js} +2 -2
- package/dist/{tus_client-83ad0f4f.js.map → tus_client-d0798623.js.map} +1 -1
- package/package.json +1 -1
- package/dist/ndm_proxy-68354a89.js +0 -13
- package/dist/ndm_proxy-68354a89.js.map +0 -1
- package/dist/ndm_proxy-c00bc561.mjs.map +0 -1
- package/dist/ndn_types-859bbd48.js +0 -2
- package/dist/ndn_types-859bbd48.js.map +0 -1
- package/dist/ndn_types-f6c08d20.mjs.map +0 -1
|
@@ -653,6 +653,108 @@ class ht {
|
|
|
653
653
|
return this.P.getHMAC(t2, n2);
|
|
654
654
|
}
|
|
655
655
|
}
|
|
656
|
+
const LEGACY_ACCOUNT_STORAGE_KEY = "buckyos.account_info";
|
|
657
|
+
const BROWSER_USER_INFO_STORAGE_KEY = "user_info";
|
|
658
|
+
function getAccountStorageKey(appId) {
|
|
659
|
+
return `buckyos.account_info.${appId}`;
|
|
660
|
+
}
|
|
661
|
+
function parseAccountInfo(raw) {
|
|
662
|
+
if (raw == null) {
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
try {
|
|
666
|
+
return JSON.parse(raw);
|
|
667
|
+
} catch {
|
|
668
|
+
return null;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function parseBrowserUserInfo(raw) {
|
|
672
|
+
if (raw == null) {
|
|
673
|
+
return null;
|
|
674
|
+
}
|
|
675
|
+
try {
|
|
676
|
+
const parsed = JSON.parse(raw);
|
|
677
|
+
const userId = typeof parsed.user_id === "string" ? parsed.user_id.trim() : "";
|
|
678
|
+
const userType = typeof parsed.user_type === "string" ? parsed.user_type.trim() : "";
|
|
679
|
+
const userNameCandidate = typeof parsed.user_name === "string" ? parsed.user_name.trim() : typeof parsed.show_name === "string" ? parsed.show_name.trim() : "";
|
|
680
|
+
if (!userId || !userType) {
|
|
681
|
+
return null;
|
|
682
|
+
}
|
|
683
|
+
return {
|
|
684
|
+
user_name: userNameCandidate || userId,
|
|
685
|
+
user_id: userId,
|
|
686
|
+
user_type: userType
|
|
687
|
+
};
|
|
688
|
+
} catch {
|
|
689
|
+
return null;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
function parseTokenAppId(sessionToken) {
|
|
693
|
+
const parts = sessionToken.split(".");
|
|
694
|
+
if (parts.length < 2) {
|
|
695
|
+
return null;
|
|
696
|
+
}
|
|
697
|
+
try {
|
|
698
|
+
const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
699
|
+
const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
|
|
700
|
+
const payload = JSON.parse(atob(padded));
|
|
701
|
+
if (typeof payload.appid === "string" && payload.appid.trim().length > 0) {
|
|
702
|
+
return payload.appid;
|
|
703
|
+
}
|
|
704
|
+
} catch {
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
return null;
|
|
708
|
+
}
|
|
709
|
+
function hashPassword(username, password, nonce = null) {
|
|
710
|
+
const shaObj = new ht("SHA-256", "TEXT", { encoding: "UTF8" });
|
|
711
|
+
shaObj.update(password + username + ".buckyos");
|
|
712
|
+
let org_password_hash_str = shaObj.getHash("B64");
|
|
713
|
+
if (nonce == null) {
|
|
714
|
+
return org_password_hash_str;
|
|
715
|
+
}
|
|
716
|
+
const shaObj2 = new ht("SHA-256", "TEXT", { encoding: "UTF8" });
|
|
717
|
+
let salt = org_password_hash_str + nonce.toString();
|
|
718
|
+
shaObj2.update(salt);
|
|
719
|
+
let result = shaObj2.getHash("B64");
|
|
720
|
+
return result;
|
|
721
|
+
}
|
|
722
|
+
function cleanLocalAccountInfo(appId) {
|
|
723
|
+
localStorage.removeItem(getAccountStorageKey(appId));
|
|
724
|
+
localStorage.removeItem(BROWSER_USER_INFO_STORAGE_KEY);
|
|
725
|
+
const legacy = parseAccountInfo(localStorage.getItem(LEGACY_ACCOUNT_STORAGE_KEY));
|
|
726
|
+
if ((legacy == null ? void 0 : legacy.session_token) && parseTokenAppId(legacy.session_token) === appId) {
|
|
727
|
+
localStorage.removeItem(LEGACY_ACCOUNT_STORAGE_KEY);
|
|
728
|
+
}
|
|
729
|
+
let cookie_options = {
|
|
730
|
+
path: "/",
|
|
731
|
+
expires: /* @__PURE__ */ new Date(0),
|
|
732
|
+
secure: true,
|
|
733
|
+
sameSite: "Lax"
|
|
734
|
+
};
|
|
735
|
+
document.cookie = `${appId}_token=; ${Object.entries(cookie_options).map(([key, value]) => `${key}=${value}`).join("; ")}`;
|
|
736
|
+
}
|
|
737
|
+
function saveLocalAccountInfo(appId, account_info) {
|
|
738
|
+
if (account_info.session_token == null) {
|
|
739
|
+
console.error("session_token is null,can't save account info");
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
localStorage.setItem(getAccountStorageKey(appId), JSON.stringify(account_info));
|
|
743
|
+
let cookie_options = {
|
|
744
|
+
path: "/",
|
|
745
|
+
expires: new Date(Date.now() + 1e3 * 60 * 60 * 24 * 30),
|
|
746
|
+
// 30天
|
|
747
|
+
secure: true,
|
|
748
|
+
sameSite: "Lax"
|
|
749
|
+
};
|
|
750
|
+
document.cookie = `${appId}_token=${account_info.session_token}; ${Object.entries(cookie_options).map(([key, value]) => `${key}=${value}`).join("; ")}`;
|
|
751
|
+
}
|
|
752
|
+
function saveBrowserUserInfo(userInfo) {
|
|
753
|
+
localStorage.setItem(BROWSER_USER_INFO_STORAGE_KEY, JSON.stringify(userInfo));
|
|
754
|
+
}
|
|
755
|
+
function getBrowserUserInfo() {
|
|
756
|
+
return parseBrowserUserInfo(localStorage.getItem(BROWSER_USER_INFO_STORAGE_KEY));
|
|
757
|
+
}
|
|
656
758
|
const DID_OBJECT_SERVICE_TYPE = "DIDObjectService";
|
|
657
759
|
const DID_OBJECT_SERVICE_ID = "#did-object";
|
|
658
760
|
const NODE_IDENTITY_SCHEMA_V2 = "buckyos.node_identity.v2";
|
|
@@ -3639,60 +3741,68 @@ const ndn_types = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
|
|
|
3639
3741
|
verifyNamedObjectFromStr
|
|
3640
3742
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3641
3743
|
export {
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3744
|
+
encodeDeviceDocument as $,
|
|
3745
|
+
canonicalize$1 as A,
|
|
3746
|
+
signJwtEdDSA as B,
|
|
3645
3747
|
ChunkId as C,
|
|
3646
3748
|
DID_OBJECT_SERVICE_TYPE as D,
|
|
3647
|
-
|
|
3749
|
+
sha256Bytes as E,
|
|
3648
3750
|
FileObject as F,
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3751
|
+
DirObject as G,
|
|
3752
|
+
newDeviceDocumentByJwk as H,
|
|
3753
|
+
verifyJwtEdDSA as I,
|
|
3754
|
+
deviceDocumentToOrderedJson as J,
|
|
3755
|
+
decodeJwtClaimWithoutVerify as K,
|
|
3756
|
+
commonjsGlobal as L,
|
|
3757
|
+
DEFAULT_EXPIRE_TIME as M,
|
|
3656
3758
|
NODE_IDENTITY_SCHEMA_V2 as N,
|
|
3657
3759
|
ObjId as O,
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3760
|
+
buckyosGetUnixTimestamp as P,
|
|
3761
|
+
getPublicKeyXFromPrivatePem as Q,
|
|
3762
|
+
getXFromJwk as R,
|
|
3661
3763
|
SimpleChunkList as S,
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3764
|
+
createJwkByX as T,
|
|
3765
|
+
newOwnerDocument as U,
|
|
3766
|
+
ownerDocumentSetDefaultZoneDid as V,
|
|
3767
|
+
ownerDocumentToOrderedJson as W,
|
|
3768
|
+
oodDescriptionToString as X,
|
|
3769
|
+
parseOODDescription as Y,
|
|
3770
|
+
encodeZoneBootDocument as Z,
|
|
3771
|
+
newZoneBootDocument as _,
|
|
3670
3772
|
ndn_types as a,
|
|
3671
|
-
|
|
3773
|
+
newDeviceMiniDocumentByDeviceDocument as a0,
|
|
3774
|
+
deviceMiniDocumentToJwt as a1,
|
|
3775
|
+
newZoneDocument as a2,
|
|
3776
|
+
encodeZoneDocument as a3,
|
|
3777
|
+
zoneDocumentToOrderedJson as a4,
|
|
3778
|
+
newDeviceMiniDocument as a5,
|
|
3779
|
+
newDeviceDocumentByMiniDocument as a6,
|
|
3780
|
+
buildNamedObjectByJson as a7,
|
|
3781
|
+
getDefaultExportFromCjs as a8,
|
|
3672
3782
|
DID_OBJECT_SERVICE_ID as b,
|
|
3673
3783
|
isBuckyOSOwnerDocument as c,
|
|
3674
3784
|
isBuckyOSDeviceMiniDocument as d,
|
|
3675
3785
|
isBuckyOSZoneBootDocument as e,
|
|
3676
3786
|
isBuckyOSNodeIdentityConfig as f,
|
|
3677
3787
|
isBuckyOSLocalNodeIdentityConfig as g,
|
|
3678
|
-
|
|
3788
|
+
hashPassword as h,
|
|
3679
3789
|
isW3CDIDDocumentBase as i,
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3790
|
+
isBuckyOSDeviceDocument as j,
|
|
3791
|
+
isBuckyOSAgentDocument as k,
|
|
3792
|
+
isBuckyOSZoneDocument as l,
|
|
3793
|
+
isBuckyOSDIDObjectCard as m,
|
|
3684
3794
|
namelib as n,
|
|
3685
|
-
|
|
3795
|
+
isBuckyOSZoneConfig as o,
|
|
3686
3796
|
parseW3CDIDDocumentBase as p,
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3797
|
+
parseBuckyOSOwnerDocument as q,
|
|
3798
|
+
parseBuckyOSDeviceMiniDocument as r,
|
|
3799
|
+
parseBuckyOSDIDDocument as s,
|
|
3800
|
+
getDidMethod as t,
|
|
3801
|
+
getDidIdentifier as u,
|
|
3692
3802
|
DID as v,
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3803
|
+
getBrowserUserInfo as w,
|
|
3804
|
+
saveBrowserUserInfo as x,
|
|
3805
|
+
saveLocalAccountInfo as y,
|
|
3806
|
+
cleanLocalAccountInfo as z
|
|
3697
3807
|
};
|
|
3698
|
-
//# sourceMappingURL=ndn_types-
|
|
3808
|
+
//# sourceMappingURL=ndn_types-d768245f.mjs.map
|