@agimon-ai/po-identity 0.0.2-alpha.103 → 0.0.2-alpha.104
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/dist/account.cjs +26 -0
- package/dist/account.d.mts +6 -0
- package/dist/account.mjs +6 -0
- package/dist/constants/accountPages.cjs +26 -0
- package/dist/constants/accountPages.d.mts +11 -0
- package/dist/constants/accountPages.mjs +24 -0
- package/dist/desktopAccount.cjs +6 -0
- package/dist/desktopAccount.d.mts +3 -0
- package/dist/desktopAccount.mjs +1 -0
- package/dist/extensions/native.cjs +21 -0
- package/dist/extensions/native.d.mts +8 -0
- package/dist/extensions/native.mjs +17 -0
- package/dist/extensions/server.cjs +11 -1
- package/dist/extensions/server.mjs +13 -3
- package/dist/phone.cjs +15 -0
- package/dist/phone.d.mts +9 -0
- package/dist/phone.mjs +5 -0
- package/dist/services/accountGrants/index.cjs +102 -0
- package/dist/services/accountGrants/index.d.mts +36 -0
- package/dist/services/accountGrants/index.mjs +102 -0
- package/dist/services/accountRoster/index.cjs +295 -0
- package/dist/services/accountRoster/index.d.mts +97 -0
- package/dist/services/accountRoster/index.mjs +286 -0
- package/dist/services/accountTrust/index.cjs +163 -0
- package/dist/services/accountTrust/index.d.mts +76 -0
- package/dist/services/accountTrust/index.mjs +159 -0
- package/dist/services/desktopAccount/index.cjs +264 -0
- package/dist/services/desktopAccount/index.d.mts +14 -0
- package/dist/services/desktopAccount/index.mjs +261 -0
- package/dist/services/desktopAccount/type.d.mts +60 -0
- package/dist/services/hostedAccount/index.cjs +197 -0
- package/dist/services/hostedAccount/index.d.mts +26 -0
- package/dist/services/hostedAccount/index.mjs +195 -0
- package/dist/services/hostedAccount/type.d.mts +43 -0
- package/dist/services/hostedAccountFlow/index.cjs +159 -0
- package/dist/services/hostedAccountFlow/index.d.mts +26 -0
- package/dist/services/hostedAccountFlow/index.mjs +158 -0
- package/dist/services/hostedAccountFlow/type.d.mts +51 -0
- package/dist/services/identityHome/index.cjs +8 -0
- package/dist/services/identityHome/index.d.mts +1 -0
- package/dist/services/identityHome/index.mjs +8 -0
- package/dist/services/issuerSelection/index.cjs +24 -0
- package/dist/services/issuerSelection/index.d.mts +12 -0
- package/dist/services/issuerSelection/index.mjs +24 -0
- package/dist/services/phoneAccount/index.cjs +377 -0
- package/dist/services/phoneAccount/index.d.mts +164 -0
- package/dist/services/phoneAccount/index.mjs +376 -0
- package/dist/services/phoneAccount/type.d.mts +45 -0
- package/dist/services/phoneAccountFlow/index.cjs +589 -0
- package/dist/services/phoneAccountFlow/index.d.mts +41 -0
- package/dist/services/phoneAccountFlow/index.mjs +587 -0
- package/dist/services/phoneAccountFlow/type.d.mts +118 -0
- package/dist/services/sharedSpace/index.cjs +29 -0
- package/dist/services/sharedSpace/index.mjs +27 -0
- package/package.json +25 -5
package/dist/account.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_accountPages = require("./constants/accountPages.cjs");
|
|
3
|
+
const require_index = require("./services/accountGrants/index.cjs");
|
|
4
|
+
const require_index$1 = require("./services/accountRoster/index.cjs");
|
|
5
|
+
const require_index$2 = require("./services/accountTrust/index.cjs");
|
|
6
|
+
const require_index$3 = require("./services/issuerSelection/index.cjs");
|
|
7
|
+
exports.ACCOUNT_BACK = require_accountPages.ACCOUNT_BACK;
|
|
8
|
+
exports.ACCOUNT_METHODS = require_accountPages.ACCOUNT_METHODS;
|
|
9
|
+
exports.SIGN_IN_UNREACHABLE = require_accountPages.SIGN_IN_UNREACHABLE;
|
|
10
|
+
exports.acceptDeviceApproval = require_index$2.acceptDeviceApproval;
|
|
11
|
+
exports.claimPairedHub = require_index$1.claimPairedHub;
|
|
12
|
+
exports.consumeAccountEvictions = require_index$1.consumeAccountEvictions;
|
|
13
|
+
exports.createAccountGrants = require_index.createAccountGrants;
|
|
14
|
+
exports.createAccountTrust = require_index$2.createAccountTrust;
|
|
15
|
+
exports.createIssuerSelection = require_index$3.createIssuerSelection;
|
|
16
|
+
exports.discoverAccountComputer = require_index$1.discoverAccountComputer;
|
|
17
|
+
exports.hasOwnerControl = require_index$2.hasOwnerControl;
|
|
18
|
+
exports.identityIssuer = require_index$2.identityIssuer;
|
|
19
|
+
exports.issuerNamespace = require_index$2.issuerNamespace;
|
|
20
|
+
exports.pairedAccountHost = require_index$1.pairedAccountHost;
|
|
21
|
+
exports.readAccountRosters = require_index$1.readAccountRosters;
|
|
22
|
+
exports.readVisibleAccountHosts = require_index$1.readVisibleAccountHosts;
|
|
23
|
+
exports.registerHostInRoster = require_index$1.registerHostInRoster;
|
|
24
|
+
exports.removeAccountHub = require_index$1.removeAccountHub;
|
|
25
|
+
exports.setAccountHostVisibility = require_index$1.setAccountHostVisibility;
|
|
26
|
+
exports.unlinkAccountHub = require_index$1.unlinkAccountHub;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ACCOUNT_BACK, ACCOUNT_METHODS, AccountPage, SIGN_IN_UNREACHABLE } from "./constants/accountPages.mjs";
|
|
2
|
+
import { AccountKeyPort, AccountRecord, AccountStorage, acceptDeviceApproval, createAccountTrust, hasOwnerControl, identityIssuer, issuerNamespace } from "./services/accountTrust/index.mjs";
|
|
3
|
+
import { GrantPorts, GrantScope, GrantStorage, SavedGrant, SignedGrant, createAccountGrants } from "./services/accountGrants/index.mjs";
|
|
4
|
+
import { AccountHost, HostRosterRegistrationPorts, claimPairedHub, consumeAccountEvictions, discoverAccountComputer, pairedAccountHost, readAccountRosters, readVisibleAccountHosts, registerHostInRoster, removeAccountHub, setAccountHostVisibility, unlinkAccountHub } from "./services/accountRoster/index.mjs";
|
|
5
|
+
import { createIssuerSelection } from "./services/issuerSelection/index.mjs";
|
|
6
|
+
export { ACCOUNT_BACK, ACCOUNT_METHODS, AccountHost, AccountKeyPort, AccountPage, AccountRecord, AccountStorage, GrantPorts, GrantScope, GrantStorage, HostRosterRegistrationPorts, SIGN_IN_UNREACHABLE, SavedGrant, SignedGrant, acceptDeviceApproval, claimPairedHub, consumeAccountEvictions, createAccountGrants, createAccountTrust, createIssuerSelection, discoverAccountComputer, hasOwnerControl, identityIssuer, issuerNamespace, pairedAccountHost, readAccountRosters, readVisibleAccountHosts, registerHostInRoster, removeAccountHub, setAccountHostVisibility, unlinkAccountHub };
|
package/dist/account.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ACCOUNT_BACK, ACCOUNT_METHODS, SIGN_IN_UNREACHABLE } from "./constants/accountPages.mjs";
|
|
2
|
+
import { createAccountGrants } from "./services/accountGrants/index.mjs";
|
|
3
|
+
import { claimPairedHub, consumeAccountEvictions, discoverAccountComputer, pairedAccountHost, readAccountRosters, readVisibleAccountHosts, registerHostInRoster, removeAccountHub, setAccountHostVisibility, unlinkAccountHub } from "./services/accountRoster/index.mjs";
|
|
4
|
+
import { acceptDeviceApproval, createAccountTrust, hasOwnerControl, identityIssuer, issuerNamespace } from "./services/accountTrust/index.mjs";
|
|
5
|
+
import { createIssuerSelection } from "./services/issuerSelection/index.mjs";
|
|
6
|
+
export { ACCOUNT_BACK, ACCOUNT_METHODS, SIGN_IN_UNREACHABLE, acceptDeviceApproval, claimPairedHub, consumeAccountEvictions, createAccountGrants, createAccountTrust, createIssuerSelection, discoverAccountComputer, hasOwnerControl, identityIssuer, issuerNamespace, pairedAccountHost, readAccountRosters, readVisibleAccountHosts, registerHostInRoster, removeAccountHub, setAccountHostVisibility, unlinkAccountHub };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/constants/accountPages.ts
|
|
2
|
+
const ACCOUNT_METHODS = [
|
|
3
|
+
"Email code",
|
|
4
|
+
"Apple",
|
|
5
|
+
"Google",
|
|
6
|
+
"Microsoft",
|
|
7
|
+
"GitHub"
|
|
8
|
+
];
|
|
9
|
+
/**
|
|
10
|
+
* Where Back leads. First run has no stack header, so without this a sub-page is a dead end. Each target is an
|
|
11
|
+
* action the account flow already handles.
|
|
12
|
+
*/
|
|
13
|
+
const ACCOUNT_BACK = {
|
|
14
|
+
methods: "welcome",
|
|
15
|
+
email: "welcome",
|
|
16
|
+
"email-code": "Email code",
|
|
17
|
+
approve: "account",
|
|
18
|
+
devices: "account",
|
|
19
|
+
delete: "account",
|
|
20
|
+
recovery: "account"
|
|
21
|
+
};
|
|
22
|
+
const SIGN_IN_UNREACHABLE = "Po can't reach your sign-in server right now. You can still pair a computer without an account.";
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.ACCOUNT_BACK = ACCOUNT_BACK;
|
|
25
|
+
exports.ACCOUNT_METHODS = ACCOUNT_METHODS;
|
|
26
|
+
exports.SIGN_IN_UNREACHABLE = SIGN_IN_UNREACHABLE;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/constants/accountPages.d.ts
|
|
2
|
+
/** The pages of the phone's self-hosted account flow. */
|
|
3
|
+
export type AccountPage = 'welcome' | 'methods' | 'email' | 'email-code' | 'recovery-chooser' | 'confirm' | 'recovery-code' | 'later-device' | 'approve' | 'recovery' | 'wait' | 'account' | 'devices' | 'delete' | 'team' | 'cloud';
|
|
4
|
+
export declare const ACCOUNT_METHODS: readonly ['Email code', 'Apple', 'Google', 'Microsoft', 'GitHub'];
|
|
5
|
+
/**
|
|
6
|
+
* Where Back leads. First run has no stack header, so without this a sub-page is a dead end. Each target is an
|
|
7
|
+
* action the account flow already handles.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ACCOUNT_BACK: Partial<Record<AccountPage, string>>;
|
|
10
|
+
export declare const SIGN_IN_UNREACHABLE = "Po can't reach your sign-in server right now. You can still pair a computer without an account.";
|
|
11
|
+
//#endregion
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/constants/accountPages.ts
|
|
2
|
+
const ACCOUNT_METHODS = [
|
|
3
|
+
"Email code",
|
|
4
|
+
"Apple",
|
|
5
|
+
"Google",
|
|
6
|
+
"Microsoft",
|
|
7
|
+
"GitHub"
|
|
8
|
+
];
|
|
9
|
+
/**
|
|
10
|
+
* Where Back leads. First run has no stack header, so without this a sub-page is a dead end. Each target is an
|
|
11
|
+
* action the account flow already handles.
|
|
12
|
+
*/
|
|
13
|
+
const ACCOUNT_BACK = {
|
|
14
|
+
methods: "welcome",
|
|
15
|
+
email: "welcome",
|
|
16
|
+
"email-code": "Email code",
|
|
17
|
+
approve: "account",
|
|
18
|
+
devices: "account",
|
|
19
|
+
delete: "account",
|
|
20
|
+
recovery: "account"
|
|
21
|
+
};
|
|
22
|
+
const SIGN_IN_UNREACHABLE = "Po can't reach your sign-in server right now. You can still pair a computer without an account.";
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ACCOUNT_BACK, ACCOUNT_METHODS, SIGN_IN_UNREACHABLE };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_index = require("./services/desktopAccount/index.cjs");
|
|
3
|
+
exports.CLOUD_ISSUER_ENV = require_index.CLOUD_ISSUER_ENV;
|
|
4
|
+
exports.DEFAULT_CLOUD_ISSUER = require_index.DEFAULT_CLOUD_ISSUER;
|
|
5
|
+
exports.createCloudAccount = require_index.createCloudAccount;
|
|
6
|
+
exports.resolveCloudIssuer = require_index.resolveCloudIssuer;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CloudAccount, CloudAccountOptions, CloudAccountRecord, CloudAccountStatus, CloudAccountStore, CloudProxy, CloudSignInStart } from "./services/desktopAccount/type.mjs";
|
|
2
|
+
import { CLOUD_ISSUER_ENV, DEFAULT_CLOUD_ISSUER, createCloudAccount, resolveCloudIssuer } from "./services/desktopAccount/index.mjs";
|
|
3
|
+
export { CLOUD_ISSUER_ENV, type CloudAccount, type CloudAccountOptions, type CloudAccountRecord, type CloudAccountStatus, type CloudAccountStore, type CloudProxy, type CloudSignInStart, DEFAULT_CLOUD_ISSUER, createCloudAccount, resolveCloudIssuer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CLOUD_ISSUER_ENV, DEFAULT_CLOUD_ISSUER, createCloudAccount, resolveCloudIssuer } from "./services/desktopAccount/index.mjs";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
//#region src/extensions/native.ts
|
|
6
|
+
/**
|
|
7
|
+
* The phone ships this plugin inside the app (po-native `bundledPlugins`), so its account and
|
|
8
|
+
* first-run fills exist before any computer is paired and never come from a host download.
|
|
9
|
+
*/
|
|
10
|
+
const nativePlugin = (0, require("@agimon-ai/po-core/native").defineNativePlugin)({
|
|
11
|
+
id: "identity",
|
|
12
|
+
packageName: "@agimon-ai/po-identity",
|
|
13
|
+
host: { fills: [{
|
|
14
|
+
slot: "onboarding-region",
|
|
15
|
+
id: "account",
|
|
16
|
+
component: ({ children }) => children
|
|
17
|
+
}] }
|
|
18
|
+
});
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.default = nativePlugin;
|
|
21
|
+
exports.nativePlugin = nativePlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/extensions/native.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The phone ships this plugin inside the app (po-native `bundledPlugins`), so its account and
|
|
4
|
+
* first-run fills exist before any computer is paired and never come from a host download.
|
|
5
|
+
*/
|
|
6
|
+
export declare const nativePlugin: import("@agimon-ai/po-core/native").WebPluginDefinition;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { nativePlugin as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineNativePlugin } from "@agimon-ai/po-core/native";
|
|
2
|
+
//#region src/extensions/native.ts
|
|
3
|
+
/**
|
|
4
|
+
* The phone ships this plugin inside the app (po-native `bundledPlugins`), so its account and
|
|
5
|
+
* first-run fills exist before any computer is paired and never come from a host download.
|
|
6
|
+
*/
|
|
7
|
+
const nativePlugin = defineNativePlugin({
|
|
8
|
+
id: "identity",
|
|
9
|
+
packageName: "@agimon-ai/po-identity",
|
|
10
|
+
host: { fills: [{
|
|
11
|
+
slot: "onboarding-region",
|
|
12
|
+
id: "account",
|
|
13
|
+
component: ({ children }) => children
|
|
14
|
+
}] }
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { nativePlugin as default, nativePlugin };
|
|
@@ -5,6 +5,7 @@ Object.defineProperties(exports, {
|
|
|
5
5
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
6
6
|
const require_index = require("../services/identityHome/index.cjs");
|
|
7
7
|
const require_index$1 = require("../services/identityConfiguration/index.cjs");
|
|
8
|
+
const require_index$2 = require("../services/sharedSpace/index.cjs");
|
|
8
9
|
let node_path = require("node:path");
|
|
9
10
|
node_path = require_runtime.__toESM(node_path, 1);
|
|
10
11
|
let _agimon_ai_po_core_piSettings = require("@agimon-ai/po-core/piSettings");
|
|
@@ -52,6 +53,12 @@ const serverPlugin = (0, require("@agimon-ai/po-core/serverPlugin").defineServer
|
|
|
52
53
|
await provider.dispose();
|
|
53
54
|
throw new Error("Identity platform services unavailable");
|
|
54
55
|
}
|
|
56
|
+
const shared = require_index$2.createSharedSpaceProvider({
|
|
57
|
+
issuer: configuration.config.issuer,
|
|
58
|
+
spaceRoot: node_path.default.join((0, _agimon_ai_po_core_piSettings.piAgentDirectory)(environment, environment.HOME), "po-space"),
|
|
59
|
+
isMember: async (subject, org) => await home?.isOrgMember(subject, org) === true
|
|
60
|
+
});
|
|
61
|
+
const space = plugin.context.inject([_agimon_ai_po_core_platform.PO_SPACE_SERVICE], (bound) => (0, _agimon_ai_po_core_platform.readPoSpace)(bound)?.registerProvider(shared));
|
|
55
62
|
return {
|
|
56
63
|
api: [{
|
|
57
64
|
basePath: "auth",
|
|
@@ -88,7 +95,10 @@ const serverPlugin = (0, require("@agimon-ai/po-core/serverPlugin").defineServer
|
|
|
88
95
|
if (timer) clearInterval(timer);
|
|
89
96
|
timer = void 0;
|
|
90
97
|
},
|
|
91
|
-
onDispose: () =>
|
|
98
|
+
onDispose: async () => {
|
|
99
|
+
await space.dispose();
|
|
100
|
+
await provider.dispose();
|
|
101
|
+
}
|
|
92
102
|
};
|
|
93
103
|
}
|
|
94
104
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createIdentityHome } from "../services/identityHome/index.mjs";
|
|
2
2
|
import { identityConfiguration } from "../services/identityConfiguration/index.mjs";
|
|
3
|
+
import { createSharedSpaceProvider } from "../services/sharedSpace/index.mjs";
|
|
3
4
|
import path from "node:path";
|
|
4
|
-
import { poHomeDirectory } from "@agimon-ai/po-core/piSettings";
|
|
5
|
-
import { BACKGROUND_CONTEXT, PO_FS_SERVICE, PO_SQLITE_SERVICE, getOrThrow, requirePoFs, requirePoSqlite } from "@agimon-ai/po-core/platform";
|
|
5
|
+
import { piAgentDirectory, poHomeDirectory } from "@agimon-ai/po-core/piSettings";
|
|
6
|
+
import { BACKGROUND_CONTEXT, PO_FS_SERVICE, PO_SPACE_SERVICE, PO_SQLITE_SERVICE, getOrThrow, readPoSpace, requirePoFs, requirePoSqlite } from "@agimon-ai/po-core/platform";
|
|
6
7
|
import { defineServerPlugin } from "@agimon-ai/po-core/serverPlugin";
|
|
7
8
|
//#region src/extensions/server.ts
|
|
8
9
|
/** Only selected global compositions install an issuer. Pairing-only hosts keep the attach gate. */
|
|
@@ -47,6 +48,12 @@ const serverPlugin = defineServerPlugin({
|
|
|
47
48
|
await provider.dispose();
|
|
48
49
|
throw new Error("Identity platform services unavailable");
|
|
49
50
|
}
|
|
51
|
+
const shared = createSharedSpaceProvider({
|
|
52
|
+
issuer: configuration.config.issuer,
|
|
53
|
+
spaceRoot: path.join(piAgentDirectory(environment, environment.HOME), "po-space"),
|
|
54
|
+
isMember: async (subject, org) => await home?.isOrgMember(subject, org) === true
|
|
55
|
+
});
|
|
56
|
+
const space = plugin.context.inject([PO_SPACE_SERVICE], (bound) => readPoSpace(bound)?.registerProvider(shared));
|
|
50
57
|
return {
|
|
51
58
|
api: [{
|
|
52
59
|
basePath: "auth",
|
|
@@ -83,7 +90,10 @@ const serverPlugin = defineServerPlugin({
|
|
|
83
90
|
if (timer) clearInterval(timer);
|
|
84
91
|
timer = void 0;
|
|
85
92
|
},
|
|
86
|
-
onDispose: () =>
|
|
93
|
+
onDispose: async () => {
|
|
94
|
+
await space.dispose();
|
|
95
|
+
await provider.dispose();
|
|
96
|
+
}
|
|
87
97
|
};
|
|
88
98
|
}
|
|
89
99
|
});
|
package/dist/phone.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_index = require("./services/phoneAccount/index.cjs");
|
|
3
|
+
const require_index$1 = require("./services/hostedAccount/index.cjs");
|
|
4
|
+
const require_index$2 = require("./services/hostedAccountFlow/index.cjs");
|
|
5
|
+
const require_index$3 = require("./services/phoneAccountFlow/index.cjs");
|
|
6
|
+
exports.accountViewModel = require_index$3.accountViewModel;
|
|
7
|
+
exports.clearExpoSession = require_index.clearExpoSession;
|
|
8
|
+
exports.createHostedAccount = require_index$1.createHostedAccount;
|
|
9
|
+
exports.createHostedAccountFlow = require_index$2.createHostedAccountFlow;
|
|
10
|
+
exports.createPhoneAccount = require_index.createPhoneAccount;
|
|
11
|
+
exports.createPhoneAccountFlow = require_index$3.createPhoneAccountFlow;
|
|
12
|
+
exports.hostedAccountViewModel = require_index$2.hostedAccountViewModel;
|
|
13
|
+
exports.hostedBootstrapOf = require_index$1.hostedBootstrapOf;
|
|
14
|
+
exports.recoveredComputers = require_index$3.recoveredComputers;
|
|
15
|
+
exports.teamSlug = require_index$1.teamSlug;
|
package/dist/phone.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PhoneAccountHost, PhoneAppleCredential, PhoneHostRequest, PhonePairedHost, PhoneSecureStore } from "./services/phoneAccount/type.mjs";
|
|
2
|
+
import { HostedAccountHost, HostedBootstrap, HostedSession, HostedTeam } from "./services/hostedAccount/type.mjs";
|
|
3
|
+
import { HostedAccount, createHostedAccount, hostedBootstrapOf, teamSlug } from "./services/hostedAccount/index.mjs";
|
|
4
|
+
import { HostedAccountFlowHost, HostedAccountFlowState, HostedAccountViewModel } from "./services/hostedAccountFlow/type.mjs";
|
|
5
|
+
import { HostedAccountFlow, createHostedAccountFlow, hostedAccountViewModel } from "./services/hostedAccountFlow/index.mjs";
|
|
6
|
+
import { AccountClient, PhoneAccount, clearExpoSession, createPhoneAccount } from "./services/phoneAccount/index.mjs";
|
|
7
|
+
import { AccountFlowState, AccountViewModel, FlowCloudHost, FlowPairedHost, PhoneAccountFlowHost, RecoveredComputer } from "./services/phoneAccountFlow/type.mjs";
|
|
8
|
+
import { PhoneAccountFlow, accountViewModel, createPhoneAccountFlow, recoveredComputers } from "./services/phoneAccountFlow/index.mjs";
|
|
9
|
+
export { AccountClient, type AccountFlowState, type AccountViewModel, type FlowCloudHost, type FlowPairedHost, HostedAccount, HostedAccountFlow, type HostedAccountFlowHost, type HostedAccountFlowState, type HostedAccountHost, type HostedAccountViewModel, type HostedBootstrap, type HostedSession, type HostedTeam, PhoneAccount, PhoneAccountFlow, type PhoneAccountFlowHost, type PhoneAccountHost, type PhoneAppleCredential, type PhoneHostRequest, type PhonePairedHost, type PhoneSecureStore, type RecoveredComputer, accountViewModel, clearExpoSession, createHostedAccount, createHostedAccountFlow, createPhoneAccount, createPhoneAccountFlow, hostedAccountViewModel, hostedBootstrapOf, recoveredComputers, teamSlug };
|
package/dist/phone.mjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { clearExpoSession, createPhoneAccount } from "./services/phoneAccount/index.mjs";
|
|
2
|
+
import { createHostedAccount, hostedBootstrapOf, teamSlug } from "./services/hostedAccount/index.mjs";
|
|
3
|
+
import { createHostedAccountFlow, hostedAccountViewModel } from "./services/hostedAccountFlow/index.mjs";
|
|
4
|
+
import { accountViewModel, createPhoneAccountFlow, recoveredComputers } from "./services/phoneAccountFlow/index.mjs";
|
|
5
|
+
export { accountViewModel, clearExpoSession, createHostedAccount, createHostedAccountFlow, createPhoneAccount, createPhoneAccountFlow, hostedAccountViewModel, hostedBootstrapOf, recoveredComputers, teamSlug };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
let _agimon_ai_po_core_native = require("@agimon-ai/po-core/native");
|
|
2
|
+
let _agimon_ai_po_web_security_browser = require("@agimon-ai/po-web-security/browser");
|
|
3
|
+
//#region src/services/accountGrants/index.ts
|
|
4
|
+
/** Native consent lifecycle. Session and calendar callers receive the envelope to hand to their host. */
|
|
5
|
+
function createAccountGrants(ports) {
|
|
6
|
+
let writes = Promise.resolve();
|
|
7
|
+
function serial(action) {
|
|
8
|
+
const result = writes.then(action);
|
|
9
|
+
writes = result.catch(() => void 0);
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
async function sign(record, scope, grantId = crypto.randomUUID()) {
|
|
13
|
+
if (!Number.isSafeInteger(record.revocationEpoch) || record.revocationEpoch < 0) throw new Error("Refresh your account before sharing work.");
|
|
14
|
+
if (!scope.operations.length || scope.operations.some((operation) => !operation)) throw new Error("Choose the work this host may do.");
|
|
15
|
+
const now = ports.now();
|
|
16
|
+
return ports.sign(record, {
|
|
17
|
+
...scope,
|
|
18
|
+
issuer: record.issuer,
|
|
19
|
+
subject: record.subject,
|
|
20
|
+
deviceKeyId: record.deviceId,
|
|
21
|
+
revocationEpoch: record.revocationEpoch,
|
|
22
|
+
grantId,
|
|
23
|
+
notBefore: now,
|
|
24
|
+
issuedAt: now,
|
|
25
|
+
expiresAt: now + _agimon_ai_po_web_security_browser.FEDERATION_FRESHNESS.grant,
|
|
26
|
+
redelegable: false
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const start = (issuer, workId, scope) => serial(async () => {
|
|
30
|
+
if (scope.callingHostId === scope.targetHostId) return void 0;
|
|
31
|
+
const record = await ports.account(issuer);
|
|
32
|
+
if (record.issuer !== issuer) throw new Error("The account belongs to another identity home.");
|
|
33
|
+
const envelope = await sign(record, scope);
|
|
34
|
+
const saved = await ports.storage.read(issuer);
|
|
35
|
+
await ports.storage.write(issuer, [...saved.filter((item) => item.workId !== workId || item.envelope.payload.callingHostId !== scope.callingHostId), {
|
|
36
|
+
workId,
|
|
37
|
+
envelope
|
|
38
|
+
}]);
|
|
39
|
+
await ports.deliver?.(workId, envelope);
|
|
40
|
+
return envelope;
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
clear: (issuer) => serial(() => ports.storage.write(issuer, [])),
|
|
44
|
+
/** Provider permissions are renewed explicitly and posted together, never renewed only on this phone. */
|
|
45
|
+
providerConsent(issuer, scope, packageName) {
|
|
46
|
+
return serial(async () => {
|
|
47
|
+
const record = await ports.account(issuer);
|
|
48
|
+
if (record.issuer !== issuer) throw new Error("The account belongs to another identity home.");
|
|
49
|
+
const { read, write } = (0, _agimon_ai_po_core_native.splitConsentOperations)(scope.operations);
|
|
50
|
+
if (!read.length || !write.length) throw new Error("This provider needs both read and write operations.");
|
|
51
|
+
const grants = [];
|
|
52
|
+
for (const operations of [read, write]) grants.push(await sign(record, {
|
|
53
|
+
...scope,
|
|
54
|
+
operations,
|
|
55
|
+
constraints: { package: packageName }
|
|
56
|
+
}));
|
|
57
|
+
return grants;
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
start,
|
|
61
|
+
onSessionStart: start,
|
|
62
|
+
onJobCreated: start,
|
|
63
|
+
/** Expired grants need an explicit renew action, never silent consent on open. */
|
|
64
|
+
onAppOpen(issuer) {
|
|
65
|
+
return serial(async () => {
|
|
66
|
+
const saved = await ports.storage.read(issuer);
|
|
67
|
+
const now = ports.now();
|
|
68
|
+
const due = saved.filter(({ envelope: { payload } }) => payload.issuer === issuer && payload.expiresAt > now && payload.expiresAt - now <= _agimon_ai_po_web_security_browser.FEDERATION_FRESHNESS.grantRenewalWindow);
|
|
69
|
+
if (!due.length) return [];
|
|
70
|
+
const record = await ports.account(issuer);
|
|
71
|
+
const renewed = [];
|
|
72
|
+
for (const item of due) {
|
|
73
|
+
if (record.issuer !== issuer || item.envelope.payload.subject !== record.subject || item.envelope.payload.revocationEpoch !== record.revocationEpoch) continue;
|
|
74
|
+
const envelope = await sign(record, item.envelope.payload, item.envelope.payload.grantId);
|
|
75
|
+
item.envelope = envelope;
|
|
76
|
+
await ports.deliver?.(item.workId, envelope);
|
|
77
|
+
renewed.push(envelope);
|
|
78
|
+
}
|
|
79
|
+
await ports.storage.write(issuer, saved);
|
|
80
|
+
return renewed;
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
renew(issuer, grantId) {
|
|
84
|
+
return serial(async () => {
|
|
85
|
+
const saved = await ports.storage.read(issuer);
|
|
86
|
+
const item = saved.find(({ envelope }) => envelope.payload.grantId === grantId && envelope.payload.issuer === issuer);
|
|
87
|
+
if (!item) throw new Error("This shared work is no longer saved on this phone.");
|
|
88
|
+
const record = await ports.account(issuer);
|
|
89
|
+
if (record.issuer !== issuer || record.subject !== item.envelope.payload.subject) throw new Error("Sign in to the account that shared this work.");
|
|
90
|
+
item.envelope = await sign(record, item.envelope.payload, grantId);
|
|
91
|
+
await ports.deliver?.(item.workId, item.envelope);
|
|
92
|
+
await ports.storage.write(issuer, saved);
|
|
93
|
+
return item.envelope;
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
async notice(issuer, event, callingHostId) {
|
|
97
|
+
return (await ports.storage.read(issuer)).find(({ workId, envelope }) => workId === event.workId && envelope.payload.grantId === event.grantId && envelope.payload.issuer === issuer && envelope.payload.callingHostId === callingHostId);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
exports.createAccountGrants = createAccountGrants;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AccountRecord } from "../accountTrust/index.mjs";
|
|
2
|
+
import { FederationEnvelope, FederationGrant } from "@agimon-ai/po-core/native";
|
|
3
|
+
import { FederationWorkPaused as FederationWorkPaused$1 } from "@agimon-ai/po-core/packageApi";
|
|
4
|
+
//#region src/services/accountGrants/index.d.ts
|
|
5
|
+
export type SignedGrant = FederationEnvelope<'po/grant/v1'>;
|
|
6
|
+
export type GrantScope = Pick<FederationGrant, 'networkId' | 'workspaceId' | 'callingHostId' | 'targetHostId' | 'callingEnrollmentGeneration' | 'targetEnrollmentGeneration' | 'operations' | 'constraints'>;
|
|
7
|
+
export interface SavedGrant {
|
|
8
|
+
workId: string;
|
|
9
|
+
envelope: SignedGrant;
|
|
10
|
+
}
|
|
11
|
+
export interface GrantStorage {
|
|
12
|
+
read(issuer: string): Promise<SavedGrant[]>;
|
|
13
|
+
write(issuer: string, grants: SavedGrant[]): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export interface GrantPorts {
|
|
16
|
+
storage: GrantStorage;
|
|
17
|
+
/** Must fetch the issuer's current device status, not cached enrollment metadata. */
|
|
18
|
+
account(issuer: string): Promise<AccountRecord>;
|
|
19
|
+
sign(record: AccountRecord, payload: FederationGrant): Promise<SignedGrant>;
|
|
20
|
+
now(): number;
|
|
21
|
+
deliver?(workId: string, envelope: SignedGrant): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/** Native consent lifecycle. Session and calendar callers receive the envelope to hand to their host. */
|
|
24
|
+
export declare function createAccountGrants(ports: GrantPorts): {
|
|
25
|
+
clear: (issuer: string) => Promise<void>;
|
|
26
|
+
/** Provider permissions are renewed explicitly and posted together, never renewed only on this phone. */
|
|
27
|
+
providerConsent(issuer: string, scope: Omit<GrantScope, 'constraints'>, packageName: string): Promise<SignedGrant[]>;
|
|
28
|
+
start: (issuer: string, workId: string, scope: GrantScope) => Promise<SignedGrant | undefined>;
|
|
29
|
+
onSessionStart: (issuer: string, workId: string, scope: GrantScope) => Promise<SignedGrant | undefined>;
|
|
30
|
+
onJobCreated: (issuer: string, workId: string, scope: GrantScope) => Promise<SignedGrant | undefined>;
|
|
31
|
+
/** Expired grants need an explicit renew action, never silent consent on open. */
|
|
32
|
+
onAppOpen(issuer: string): Promise<SignedGrant[]>;
|
|
33
|
+
renew(issuer: string, grantId: string): Promise<SignedGrant>;
|
|
34
|
+
notice(issuer: string, event: FederationWorkPaused$1, callingHostId: string): Promise<SavedGrant | undefined>;
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { splitConsentOperations } from "@agimon-ai/po-core/native";
|
|
2
|
+
import { FEDERATION_FRESHNESS } from "@agimon-ai/po-web-security/browser";
|
|
3
|
+
//#region src/services/accountGrants/index.ts
|
|
4
|
+
/** Native consent lifecycle. Session and calendar callers receive the envelope to hand to their host. */
|
|
5
|
+
function createAccountGrants(ports) {
|
|
6
|
+
let writes = Promise.resolve();
|
|
7
|
+
function serial(action) {
|
|
8
|
+
const result = writes.then(action);
|
|
9
|
+
writes = result.catch(() => void 0);
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
async function sign(record, scope, grantId = crypto.randomUUID()) {
|
|
13
|
+
if (!Number.isSafeInteger(record.revocationEpoch) || record.revocationEpoch < 0) throw new Error("Refresh your account before sharing work.");
|
|
14
|
+
if (!scope.operations.length || scope.operations.some((operation) => !operation)) throw new Error("Choose the work this host may do.");
|
|
15
|
+
const now = ports.now();
|
|
16
|
+
return ports.sign(record, {
|
|
17
|
+
...scope,
|
|
18
|
+
issuer: record.issuer,
|
|
19
|
+
subject: record.subject,
|
|
20
|
+
deviceKeyId: record.deviceId,
|
|
21
|
+
revocationEpoch: record.revocationEpoch,
|
|
22
|
+
grantId,
|
|
23
|
+
notBefore: now,
|
|
24
|
+
issuedAt: now,
|
|
25
|
+
expiresAt: now + FEDERATION_FRESHNESS.grant,
|
|
26
|
+
redelegable: false
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const start = (issuer, workId, scope) => serial(async () => {
|
|
30
|
+
if (scope.callingHostId === scope.targetHostId) return void 0;
|
|
31
|
+
const record = await ports.account(issuer);
|
|
32
|
+
if (record.issuer !== issuer) throw new Error("The account belongs to another identity home.");
|
|
33
|
+
const envelope = await sign(record, scope);
|
|
34
|
+
const saved = await ports.storage.read(issuer);
|
|
35
|
+
await ports.storage.write(issuer, [...saved.filter((item) => item.workId !== workId || item.envelope.payload.callingHostId !== scope.callingHostId), {
|
|
36
|
+
workId,
|
|
37
|
+
envelope
|
|
38
|
+
}]);
|
|
39
|
+
await ports.deliver?.(workId, envelope);
|
|
40
|
+
return envelope;
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
clear: (issuer) => serial(() => ports.storage.write(issuer, [])),
|
|
44
|
+
/** Provider permissions are renewed explicitly and posted together, never renewed only on this phone. */
|
|
45
|
+
providerConsent(issuer, scope, packageName) {
|
|
46
|
+
return serial(async () => {
|
|
47
|
+
const record = await ports.account(issuer);
|
|
48
|
+
if (record.issuer !== issuer) throw new Error("The account belongs to another identity home.");
|
|
49
|
+
const { read, write } = splitConsentOperations(scope.operations);
|
|
50
|
+
if (!read.length || !write.length) throw new Error("This provider needs both read and write operations.");
|
|
51
|
+
const grants = [];
|
|
52
|
+
for (const operations of [read, write]) grants.push(await sign(record, {
|
|
53
|
+
...scope,
|
|
54
|
+
operations,
|
|
55
|
+
constraints: { package: packageName }
|
|
56
|
+
}));
|
|
57
|
+
return grants;
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
start,
|
|
61
|
+
onSessionStart: start,
|
|
62
|
+
onJobCreated: start,
|
|
63
|
+
/** Expired grants need an explicit renew action, never silent consent on open. */
|
|
64
|
+
onAppOpen(issuer) {
|
|
65
|
+
return serial(async () => {
|
|
66
|
+
const saved = await ports.storage.read(issuer);
|
|
67
|
+
const now = ports.now();
|
|
68
|
+
const due = saved.filter(({ envelope: { payload } }) => payload.issuer === issuer && payload.expiresAt > now && payload.expiresAt - now <= FEDERATION_FRESHNESS.grantRenewalWindow);
|
|
69
|
+
if (!due.length) return [];
|
|
70
|
+
const record = await ports.account(issuer);
|
|
71
|
+
const renewed = [];
|
|
72
|
+
for (const item of due) {
|
|
73
|
+
if (record.issuer !== issuer || item.envelope.payload.subject !== record.subject || item.envelope.payload.revocationEpoch !== record.revocationEpoch) continue;
|
|
74
|
+
const envelope = await sign(record, item.envelope.payload, item.envelope.payload.grantId);
|
|
75
|
+
item.envelope = envelope;
|
|
76
|
+
await ports.deliver?.(item.workId, envelope);
|
|
77
|
+
renewed.push(envelope);
|
|
78
|
+
}
|
|
79
|
+
await ports.storage.write(issuer, saved);
|
|
80
|
+
return renewed;
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
renew(issuer, grantId) {
|
|
84
|
+
return serial(async () => {
|
|
85
|
+
const saved = await ports.storage.read(issuer);
|
|
86
|
+
const item = saved.find(({ envelope }) => envelope.payload.grantId === grantId && envelope.payload.issuer === issuer);
|
|
87
|
+
if (!item) throw new Error("This shared work is no longer saved on this phone.");
|
|
88
|
+
const record = await ports.account(issuer);
|
|
89
|
+
if (record.issuer !== issuer || record.subject !== item.envelope.payload.subject) throw new Error("Sign in to the account that shared this work.");
|
|
90
|
+
item.envelope = await sign(record, item.envelope.payload, grantId);
|
|
91
|
+
await ports.deliver?.(item.workId, item.envelope);
|
|
92
|
+
await ports.storage.write(issuer, saved);
|
|
93
|
+
return item.envelope;
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
async notice(issuer, event, callingHostId) {
|
|
97
|
+
return (await ports.storage.read(issuer)).find(({ workId, envelope }) => workId === event.workId && envelope.payload.grantId === event.grantId && envelope.payload.issuer === issuer && envelope.payload.callingHostId === callingHostId);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { createAccountGrants };
|