@ovok/native 1.16.1-dev.2147 → 1.16.1-dev.2151
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/lib/commonjs/modules/auth/google-return-page/index.js +24 -0
- package/lib/commonjs/modules/auth/google-return-page/index.js.map +1 -0
- package/lib/commonjs/modules/auth/hooks/use-social-sign-in.web.js +15 -0
- package/lib/commonjs/modules/auth/hooks/use-social-sign-in.web.js.map +1 -0
- package/lib/commonjs/modules/auth/index.js +21 -10
- package/lib/commonjs/modules/auth/index.js.map +1 -1
- package/lib/commonjs/modules/auth/session/logout-session.js +1 -1
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/apple-login-button.web.js +73 -0
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/apple-login-button.web.js.map +1 -0
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/apple-login.js +1 -1
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/google-login-button.web.js +73 -0
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/google-login-button.web.js.map +1 -0
- package/lib/commonjs/modules/auth/sign-in/components/social-logins/google-login.js +1 -1
- package/lib/commonjs/modules/auth/sign-in/index.js +24 -0
- package/lib/commonjs/modules/auth/sign-in/index.js.map +1 -1
- package/lib/commonjs/modules/auth/sign-in/utils/apple-web-sign-in.js +90 -0
- package/lib/commonjs/modules/auth/sign-in/utils/apple-web-sign-in.js.map +1 -0
- package/lib/commonjs/modules/auth/sign-in/utils/google-redirect-sign-in.js +89 -0
- package/lib/commonjs/modules/auth/sign-in/utils/google-redirect-sign-in.js.map +1 -0
- package/lib/commonjs/modules/auth/sign-in/utils/jwt-claims.js +21 -0
- package/lib/commonjs/modules/auth/sign-in/utils/jwt-claims.js.map +1 -0
- package/lib/commonjs/modules/auth/utils/sign-out-google.web.js +10 -0
- package/lib/commonjs/modules/auth/utils/sign-out-google.web.js.map +1 -0
- package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.history-sequencer.js +13 -0
- package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.history-sequencer.js.map +1 -1
- package/lib/module/modules/auth/google-return-page/index.js +21 -0
- package/lib/module/modules/auth/google-return-page/index.js.map +1 -0
- package/lib/module/modules/auth/hooks/use-social-sign-in.web.js +10 -0
- package/lib/module/modules/auth/hooks/use-social-sign-in.web.js.map +1 -0
- package/lib/module/modules/auth/index.js +2 -1
- package/lib/module/modules/auth/index.js.map +1 -1
- package/lib/module/modules/auth/session/logout-session.js +1 -1
- package/lib/module/modules/auth/session/logout-session.js.map +1 -1
- package/lib/module/modules/auth/sign-in/components/social-logins/apple-login-button.web.js +67 -0
- package/lib/module/modules/auth/sign-in/components/social-logins/apple-login-button.web.js.map +1 -0
- package/lib/module/modules/auth/sign-in/components/social-logins/apple-login.js +1 -1
- package/lib/module/modules/auth/sign-in/components/social-logins/apple-login.js.map +1 -1
- package/lib/module/modules/auth/sign-in/components/social-logins/google-login-button.web.js +68 -0
- package/lib/module/modules/auth/sign-in/components/social-logins/google-login-button.web.js.map +1 -0
- package/lib/module/modules/auth/sign-in/components/social-logins/google-login.js +1 -1
- package/lib/module/modules/auth/sign-in/components/social-logins/google-login.js.map +1 -1
- package/lib/module/modules/auth/sign-in/index.js +2 -0
- package/lib/module/modules/auth/sign-in/index.js.map +1 -1
- package/lib/module/modules/auth/sign-in/utils/apple-web-sign-in.js +84 -0
- package/lib/module/modules/auth/sign-in/utils/apple-web-sign-in.js.map +1 -0
- package/lib/module/modules/auth/sign-in/utils/google-redirect-sign-in.js +84 -0
- package/lib/module/modules/auth/sign-in/utils/google-redirect-sign-in.js.map +1 -0
- package/lib/module/modules/auth/sign-in/utils/jwt-claims.js +17 -0
- package/lib/module/modules/auth/sign-in/utils/jwt-claims.js.map +1 -0
- package/lib/module/modules/auth/utils/sign-out-google.web.js +5 -0
- package/lib/module/modules/auth/utils/sign-out-google.web.js.map +1 -0
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.history-sequencer.js +13 -0
- package/lib/module/modules/bt-management/services/devices/bp2/bp2.history-sequencer.js.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/google-return-page/index.d.ts +8 -0
- package/lib/typescript/commonjs/src/modules/auth/google-return-page/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-social-sign-in.web.d.ts +7 -0
- package/lib/typescript/commonjs/src/modules/auth/hooks/use-social-sign-in.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/modules/auth/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/register/components/register.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/sign-in.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/social-logins/apple-login-button.web.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/social-logins/apple-login-button.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/social-logins/apple-login.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/social-logins/google-login-button.web.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/social-logins/google-login-button.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/social-logins/google-login.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/auth/sign-in/components/social-logins/social-logins.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/auth/sign-in/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/sign-in/types/apple-login-props.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/types/apple-login-props.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/sign-in/types/google-login-props.d.ts +13 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/types/google-login-props.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/auth/sign-in/utils/apple-web-sign-in.d.ts +17 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/utils/apple-web-sign-in.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/utils/google-redirect-sign-in.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/utils/google-redirect-sign-in.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/utils/jwt-claims.d.ts +9 -0
- package/lib/typescript/commonjs/src/modules/auth/sign-in/utils/jwt-claims.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/auth/utils/sign-out-google.web.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/auth/utils/sign-out-google.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.history-sequencer.d.ts +7 -1
- package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.history-sequencer.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/google-return-page/index.d.ts +8 -0
- package/lib/typescript/module/src/modules/auth/google-return-page/index.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-social-sign-in.web.d.ts +7 -0
- package/lib/typescript/module/src/modules/auth/hooks/use-social-sign-in.web.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/index.d.ts +1 -0
- package/lib/typescript/module/src/modules/auth/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/register/components/register.d.ts +2 -2
- package/lib/typescript/module/src/modules/auth/sign-in/components/sign-in.d.ts +2 -2
- package/lib/typescript/module/src/modules/auth/sign-in/components/social-logins/apple-login-button.web.d.ts +5 -0
- package/lib/typescript/module/src/modules/auth/sign-in/components/social-logins/apple-login-button.web.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/sign-in/components/social-logins/apple-login.d.ts +1 -1
- package/lib/typescript/module/src/modules/auth/sign-in/components/social-logins/google-login-button.web.d.ts +5 -0
- package/lib/typescript/module/src/modules/auth/sign-in/components/social-logins/google-login-button.web.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/sign-in/components/social-logins/google-login.d.ts +1 -1
- package/lib/typescript/module/src/modules/auth/sign-in/components/social-logins/social-logins.d.ts +2 -2
- package/lib/typescript/module/src/modules/auth/sign-in/index.d.ts +2 -0
- package/lib/typescript/module/src/modules/auth/sign-in/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/sign-in/types/apple-login-props.d.ts +13 -0
- package/lib/typescript/module/src/modules/auth/sign-in/types/apple-login-props.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/sign-in/types/google-login-props.d.ts +13 -0
- package/lib/typescript/module/src/modules/auth/sign-in/types/google-login-props.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/auth/sign-in/utils/apple-web-sign-in.d.ts +17 -0
- package/lib/typescript/module/src/modules/auth/sign-in/utils/apple-web-sign-in.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/sign-in/utils/google-redirect-sign-in.d.ts +14 -0
- package/lib/typescript/module/src/modules/auth/sign-in/utils/google-redirect-sign-in.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/sign-in/utils/jwt-claims.d.ts +9 -0
- package/lib/typescript/module/src/modules/auth/sign-in/utils/jwt-claims.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/auth/utils/sign-out-google.web.d.ts +3 -0
- package/lib/typescript/module/src/modules/auth/utils/sign-out-google.web.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.history-sequencer.d.ts +7 -1
- package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.history-sequencer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.jwtClaims = void 0;
|
|
7
|
+
/** The claims web sign-in reads from a provider's JWT. */
|
|
8
|
+
|
|
9
|
+
const asClaims = value => typeof value === "object" && value !== null ? value : {};
|
|
10
|
+
|
|
11
|
+
/** A JWT's claims, read without checking the signature; Ovok verifies the token itself. */
|
|
12
|
+
const jwtClaims = jwt => {
|
|
13
|
+
try {
|
|
14
|
+
const payload = (jwt.split(".")[1] ?? "").replace(/-/g, "+").replace(/_/g, "/");
|
|
15
|
+
return asClaims(JSON.parse(atob(payload)));
|
|
16
|
+
} catch {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.jwtClaims = jwtClaims;
|
|
21
|
+
//# sourceMappingURL=jwt-claims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asClaims","value","jwtClaims","jwt","payload","split","replace","JSON","parse","atob","exports"],"sourceRoot":"../../../../../../src","sources":["modules/auth/sign-in/utils/jwt-claims.ts"],"mappings":";;;;;;AAAA;;AAMA,MAAMA,QAAQ,GAAIC,KAAc,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,GAAIA,KAAK,GAAiB,CAAC,CAAC;;AAEzE;AACA,MAAMC,SAAS,GAAIC,GAAW,IAAgB;EAC5C,IAAI;IACF,MAAMC,OAAO,GAAG,CAACD,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAEC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;IAE/E,OAAON,QAAQ,CAACO,IAAI,CAACC,KAAK,CAACC,IAAI,CAACL,OAAO,CAAC,CAAC,CAAC;EAC5C,CAAC,CAAC,MAAM;IACN,OAAO,CAAC,CAAC;EACX;AACF,CAAC;AAACM,OAAA,CAAAR,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.signOutGoogleIfNeeded = void 0;
|
|
7
|
+
/** The web keeps no Google account in the app, so there is nothing to clear. */
|
|
8
|
+
const signOutGoogleIfNeeded = async () => undefined;
|
|
9
|
+
exports.signOutGoogleIfNeeded = signOutGoogleIfNeeded;
|
|
10
|
+
//# sourceMappingURL=sign-out-google.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["signOutGoogleIfNeeded","undefined","exports"],"sourceRoot":"../../../../../src","sources":["modules/auth/utils/sign-out-google.web.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,qBAAqB,GAAG,MAAAA,CAAA,KAA2BC,SAAS;AAACC,OAAA,CAAAF,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -18,6 +18,9 @@ const BP2_RESULT_STATES = new Set(["05", "07", "11"]);
|
|
|
18
18
|
const BP2_ECG_STATE = "06";
|
|
19
19
|
const BP2_IDLE_STATES = new Set(["00", "01", "03"]);
|
|
20
20
|
const BP2_POLL_INTERVAL_MS = 200;
|
|
21
|
+
|
|
22
|
+
/** How long a realtime poll may go unanswered before it is sent again. */
|
|
23
|
+
const BP2_POLL_ANSWER_TIMEOUT_MS = 1_000;
|
|
21
24
|
/** Reads unseen BP2 history on connect and after each realtime result. */
|
|
22
25
|
class BP2HistorySequencer {
|
|
23
26
|
builder = new _lepuCommandBuilder.LepuCommandBuilder();
|
|
@@ -38,6 +41,15 @@ class BP2HistorySequencer {
|
|
|
38
41
|
return this.startTransfer();
|
|
39
42
|
};
|
|
40
43
|
isHistoryTransfer = () => true;
|
|
44
|
+
commandTimeoutMs = () => this.isPolling() ? BP2_POLL_ANSWER_TIMEOUT_MS : undefined;
|
|
45
|
+
|
|
46
|
+
/** The BP2 can drop a poll while it starts measuring, so a missing answer is asked for again. */
|
|
47
|
+
onCommandTimeout = () => this.isPolling() ? {
|
|
48
|
+
commands: [this.pollCommand()]
|
|
49
|
+
} : {};
|
|
50
|
+
|
|
51
|
+
/** Only the realtime answer settles a poll; any other frame leaves its timeout running. */
|
|
52
|
+
commandProgress = frame => this.isPolling() && (0, _lepuFrame.lepuCommandOf)(frame) !== BP2_REALTIME_COMMAND ? "ignored" : "complete";
|
|
41
53
|
nextCommand = frame => {
|
|
42
54
|
if (this.phase === "clock") {
|
|
43
55
|
if ((0, _lepuFrame.lepuCommandOf)(frame) !== _lepuCommands.LepuCommand.SET_TIME) {
|
|
@@ -85,6 +97,7 @@ class BP2HistorySequencer {
|
|
|
85
97
|
this.params.onTransferFinished();
|
|
86
98
|
return [this.pollCommand()];
|
|
87
99
|
};
|
|
100
|
+
isPolling = () => this.phase === "files" && this.transfer === undefined;
|
|
88
101
|
pollCommand = () => ({
|
|
89
102
|
...this.params.write,
|
|
90
103
|
frame: this.builder.build(BP2_REALTIME_COMMAND),
|
package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.history-sequencer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_sentryLogger","require","_clockSync","_hexToByte","_lepuCommandBuilder","_lepuCommands","_lepuEcgTransfer","_lepuFileTransfer","_lepuFrame","_lepuResponseType","BP2_REALTIME_COMMAND","exports","BP2_RESULT_STATES","Set","BP2_ECG_STATE","BP2_IDLE_STATES","BP2_POLL_INTERVAL_MS","BP2HistorySequencer","builder","LepuCommandBuilder","lastRunStatusFrameCount","realtimeEcgActive","phase","constructor","params","initialCommands","isClockSyncEnabled","clockSync","write","frame","build","LepuCommand","SET_TIME","clockPayload","startTransfer","isHistoryTransfer","
|
|
1
|
+
{"version":3,"names":["_sentryLogger","require","_clockSync","_hexToByte","_lepuCommandBuilder","_lepuCommands","_lepuEcgTransfer","_lepuFileTransfer","_lepuFrame","_lepuResponseType","BP2_REALTIME_COMMAND","exports","BP2_RESULT_STATES","Set","BP2_ECG_STATE","BP2_IDLE_STATES","BP2_POLL_INTERVAL_MS","BP2_POLL_ANSWER_TIMEOUT_MS","BP2HistorySequencer","builder","LepuCommandBuilder","lastRunStatusFrameCount","realtimeEcgActive","phase","constructor","params","initialCommands","isClockSyncEnabled","clockSync","write","frame","build","LepuCommand","SET_TIME","clockPayload","startTransfer","isHistoryTransfer","commandTimeoutMs","isPolling","undefined","onCommandTimeout","commands","pollCommand","commandProgress","lepuCommandOf","nextCommand","isLepuSuccess","onError","describeLepuResponseType","transfer","logRunStatus","isResult","isResultFrame","endedWithoutResult","isIdleFrame","onOrphanStreamEnd","shouldStartTransfer","onTransferRequested","delayBeforeWriteMs","LepuFileTransfer","onFile","skipFiles","afterTransfer","finishTransfer","onTransferFinished","hexToByte","has","toLowerCase","runStatus","lastRunStatus","sentryLogger"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/bp2/bp2.history-sequencer.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AASA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AAKA,MAAMS,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,IAAI;AACjC,MAAME,iBAAiB,GAAG,IAAIC,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACrD,MAAMC,aAAa,GAAG,IAAI;AAC1B,MAAMC,eAAe,GAAG,IAAIF,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACnD,MAAMG,oBAAoB,GAAG,GAAG;;AAEhC;AACA,MAAMC,0BAA0B,GAAG,KAAK;AAgBxC;AACA,MAAMC,mBAAmB,CA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C,IAAI,GAAG,CAAC,KAAKpB,oBAAoB,IACnDK,eAAe,CAACmD,GAAG,CAAC,CAACpC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAEqC,WAAW,CAAC,CAAC,CAAC;EAE7CjB,YAAY,GAAIpB,KAAwB,IAAW;IACzD,IAAI,IAAAmC,oBAAS,EAACnC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAKpB,oBAAoB,EAAE;MACvD;IACF;IAEA,MAAM0D,SAAS,GAAG,CAACtC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAEqC,WAAW,CAAC,CAAC;IAEhD,IAAIC,SAAS,KAAKtD,aAAa,EAAE;MAC/B,IAAI,CAACQ,iBAAiB,GAAG,IAAI;IAC/B;IAEA,IAAI8C,SAAS,KAAK,IAAI,CAACC,aAAa,EAAE;MACpC,IAAI,CAAChD,uBAAuB,EAAE;MAE9B;IACF;IAEA,IAAI,IAAI,CAACgD,aAAa,KAAK9B,SAAS,EAAE;MACpC,IAAA+B,0BAAY,EAAC,MAAM,EAAE,oCAAoC,CAAC;IAC5D;IAEA,IAAI,CAACD,aAAa,GAAGD,SAAS;IAC9B,IAAI,CAAC/C,uBAAuB,GAAG,CAAC;EAClC,CAAC;AACH;AAACV,OAAA,CAAAO,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { GOOGLE_ANSWER_KEY, GOOGLE_REQUEST_KEY } from "../sign-in/utils/google-redirect-sign-in.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The page Google returns to when `GoogleLogin` signs in on the web.
|
|
7
|
+
*
|
|
8
|
+
* Serve it as a static file at the redirect URI, by default `/oauth/google.html`. It keeps Google's answer
|
|
9
|
+
* for this tab and sends the tab back to the sign-in screen, so the token never stays in the address.
|
|
10
|
+
*/
|
|
11
|
+
export const GOOGLE_RETURN_PAGE_HTML = `<!doctype html>
|
|
12
|
+
<meta charset="utf-8">
|
|
13
|
+
<title>Signing in</title>
|
|
14
|
+
<script>
|
|
15
|
+
var request = JSON.parse(sessionStorage.getItem("${GOOGLE_REQUEST_KEY}") || "{}");
|
|
16
|
+
var target = new URL(request.returnTo || "/", location.origin);
|
|
17
|
+
sessionStorage.setItem("${GOOGLE_ANSWER_KEY}", location.hash.slice(1));
|
|
18
|
+
location.replace(target.origin === location.origin ? target.href : "/");
|
|
19
|
+
</script>
|
|
20
|
+
`;
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GOOGLE_ANSWER_KEY","GOOGLE_REQUEST_KEY","GOOGLE_RETURN_PAGE_HTML"],"sourceRoot":"../../../../../src","sources":["modules/auth/google-return-page/index.ts"],"mappings":";;AAAA,SACEA,iBAAiB,EACjBC,kBAAkB,QACb,6CAA0C;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAA+B,GAAG;AAC/C;AACA;AACA;AACA,qDAAqDD,kBAAkB;AACvE;AACA,4BAA4BD,iBAAiB;AAC7C;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useAuthAction } from "./use-auth-action.js";
|
|
4
|
+
const NOT_ON_THE_WEB = "useSocialSignIn is not available on the web; render SignIn.SocialLogins.GoogleLogin or AppleLogin instead";
|
|
5
|
+
|
|
6
|
+
/** Rejects: the web signs in through the `SignIn.SocialLogins` buttons, which leave and return to the page. */
|
|
7
|
+
export const useSocialSignIn = _options => useAuthAction(async () => {
|
|
8
|
+
throw new Error(NOT_ON_THE_WEB);
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=use-social-sign-in.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useAuthAction","NOT_ON_THE_WEB","useSocialSignIn","_options","Error"],"sourceRoot":"../../../../../src","sources":["modules/auth/hooks/use-social-sign-in.web.ts"],"mappings":";;AAGA,SAASA,aAAa,QAAQ,sBAAmB;AAEjD,MAAMC,cAAc,GAClB,2GAA2G;;AAE7G;AACA,OAAO,MAAMC,eAAe,GAAIC,QAA6B,IAC3DH,aAAa,CAAC,YAA8B;EAC1C,MAAM,IAAII,KAAK,CAACH,cAAc,CAAC;AACjC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import "./default-translation.js";
|
|
11
11
|
export * from "./sign-in/index.js";
|
|
12
|
+
export * from "./google-return-page/index.js";
|
|
12
13
|
export * from "./register/index.js";
|
|
13
14
|
export * from "./profile/index.js";
|
|
14
15
|
export * from "./delete-account-button/index.js";
|
|
@@ -18,7 +19,7 @@ export * from "./hooks/use-rate-limit-cooldown.js";
|
|
|
18
19
|
export * from "./hooks/use-auth-action.js";
|
|
19
20
|
export * from "./hooks/use-sign-in.js";
|
|
20
21
|
export * from "./hooks/use-accept-invite-link.js";
|
|
21
|
-
export * from "./hooks/use-social-sign-in
|
|
22
|
+
export * from "./hooks/use-social-sign-in";
|
|
22
23
|
export * from "./hooks/use-sign-out.js";
|
|
23
24
|
export * from "./hooks/use-delete-account.js";
|
|
24
25
|
export * from "./utils/rate-limit.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["modules/auth/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,0BAAuB;AAE9B,cAAc,oBAAW;AACzB,cAAc,qBAAY;AAC1B,cAAc,oBAAW;AACzB,cAAc,kCAAyB;AACvC,cAAc,0BAAiB;AAC/B,cAAc,2BAAkB;AAChC,cAAc,oCAAiC;AAC/C,cAAc,4BAAyB;AACvC,cAAc,wBAAqB;AACnC,cAAc,mCAAgC;AAC9C,cAAc
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["modules/auth/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,0BAAuB;AAE9B,cAAc,oBAAW;AACzB,cAAc,+BAAsB;AACpC,cAAc,qBAAY;AAC1B,cAAc,oBAAW;AACzB,cAAc,kCAAyB;AACvC,cAAc,0BAAiB;AAC/B,cAAc,2BAAkB;AAChC,cAAc,oCAAiC;AAC/C,cAAc,4BAAyB;AACvC,cAAc,wBAAqB;AACnC,cAAc,mCAAgC;AAC9C,cAAc,4BAA4B;AAC1C,cAAc,yBAAsB;AACpC,cAAc,+BAA4B;AAC1C,cAAc,uBAAoB;AAClC,cAAc,0BAAuB;AACrC,cAAc,wBAAqB;AACnC,cAAc,oBAAW","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { signOutGoogleIfNeeded } from "../utils/sign-out-google
|
|
3
|
+
import { signOutGoogleIfNeeded } from "../utils/sign-out-google";
|
|
4
4
|
const logoutRequests = new WeakMap();
|
|
5
5
|
const logoutInProgress = new WeakSet();
|
|
6
6
|
const isLogoutInProgress = client => logoutInProgress.has(client);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["signOutGoogleIfNeeded","logoutRequests","WeakMap","logoutInProgress","WeakSet","isLogoutInProgress","client","has","logoutSession","key","pending","get","add","request","auth","logout","finally","delete","set"],"sourceRoot":"../../../../../src","sources":["modules/auth/session/logout-session.ts"],"mappings":";;AAEA,SAASA,qBAAqB,QAAQ,
|
|
1
|
+
{"version":3,"names":["signOutGoogleIfNeeded","logoutRequests","WeakMap","logoutInProgress","WeakSet","isLogoutInProgress","client","has","logoutSession","key","pending","get","add","request","auth","logout","finally","delete","set"],"sourceRoot":"../../../../../src","sources":["modules/auth/session/logout-session.ts"],"mappings":";;AAEA,SAASA,qBAAqB,QAAQ,0BAA0B;AAEhE,MAAMC,cAAc,GAAG,IAAIC,OAAO,CAAwB,CAAC;AAC3D,MAAMC,gBAAgB,GAAG,IAAIC,OAAO,CAAS,CAAC;AAE9C,MAAMC,kBAAkB,GAAIC,MAAc,IACxCH,gBAAgB,CAACI,GAAG,CAACD,MAAM,CAAC;;AAE9B;AACA,MAAME,aAAa,GAAIF,MAAY,IAAoB;EACrD,MAAMG,GAAG,GAAGH,MAAgB;EAC5B,MAAMI,OAAO,GAAGT,cAAc,CAACU,GAAG,CAACF,GAAG,CAAC;EAEvC,IAAIC,OAAO,EAAE;IACX,OAAOA,OAAO;EAChB;EAEAP,gBAAgB,CAACS,GAAG,CAACH,GAAG,CAAC;EAEzB,MAAMI,OAAO,GAAG,CAAC,YAAY;IAC3B,IAAI;MACF,MAAMP,MAAM,CAACQ,IAAI,CAACC,MAAM,CAAC,CAAC;IAC5B,CAAC,SAAS;MACR,MAAMf,qBAAqB,CAAC,CAAC;IAC/B;EACF,CAAC,EAAE,CAAC,CAACgB,OAAO,CAAC,MAAM;IACjBf,cAAc,CAACgB,MAAM,CAACR,GAAG,CAAC;IAC1BN,gBAAgB,CAACc,MAAM,CAACR,GAAG,CAAC;EAC9B,CAAC,CAAC;EAEFR,cAAc,CAACiB,GAAG,CAACT,GAAG,EAAEI,OAAO,CAAC;EAEhC,OAAOA,OAAO;AAChB,CAAC;AAED,SAASR,kBAAkB,EAAEG,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useOvok } from "@ovok/core/next/react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { parseSignInError } from "../../../utils/sign-in-error.js";
|
|
6
|
+
import { isAppleCancel, loadAppleScript, signInWithApple } from "../../utils/apple-web-sign-in.js";
|
|
7
|
+
import { SocialLoginButton } from "./social-login-button.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const AppleServicesLoginButton = ({
|
|
10
|
+
appleServicesId,
|
|
11
|
+
appleRedirectUri,
|
|
12
|
+
internalId,
|
|
13
|
+
onSuccess,
|
|
14
|
+
onError,
|
|
15
|
+
testID,
|
|
16
|
+
style,
|
|
17
|
+
disabled,
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}) => {
|
|
21
|
+
const client = useOvok();
|
|
22
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
23
|
+
const handleAppleLogin = React.useCallback(async () => {
|
|
24
|
+
try {
|
|
25
|
+
setIsLoading(true);
|
|
26
|
+
const credentials = await signInWithApple({
|
|
27
|
+
servicesId: appleServicesId,
|
|
28
|
+
redirectUri: appleRedirectUri
|
|
29
|
+
});
|
|
30
|
+
const loginResponse = await client.auth.socialLogin("apple", {
|
|
31
|
+
...credentials,
|
|
32
|
+
internalId
|
|
33
|
+
});
|
|
34
|
+
onSuccess?.(loginResponse);
|
|
35
|
+
} catch (cause) {
|
|
36
|
+
if (!isAppleCancel(cause)) {
|
|
37
|
+
onError?.(parseSignInError(cause).error);
|
|
38
|
+
}
|
|
39
|
+
} finally {
|
|
40
|
+
setIsLoading(false);
|
|
41
|
+
}
|
|
42
|
+
}, [appleRedirectUri, appleServicesId, client, internalId, onError, onSuccess]);
|
|
43
|
+
|
|
44
|
+
// Browsers only open the popup right after a tap, so Apple's script is loaded before one.
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
loadAppleScript().catch(() => undefined);
|
|
47
|
+
}, []);
|
|
48
|
+
return /*#__PURE__*/_jsx(SocialLoginButton, {
|
|
49
|
+
...props,
|
|
50
|
+
backgroundColor: "#000",
|
|
51
|
+
style: style,
|
|
52
|
+
disabled: disabled || isLoading,
|
|
53
|
+
onPress: handleAppleLogin,
|
|
54
|
+
testID: testID,
|
|
55
|
+
children: children
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** Sign in with Apple in a popup, for the Services ID registered for this site; renders nothing without one. */
|
|
60
|
+
export const AppleLoginButton = ({
|
|
61
|
+
appleServicesId,
|
|
62
|
+
...props
|
|
63
|
+
}) => appleServicesId ? /*#__PURE__*/_jsx(AppleServicesLoginButton, {
|
|
64
|
+
...props,
|
|
65
|
+
appleServicesId: appleServicesId
|
|
66
|
+
}) : null;
|
|
67
|
+
//# sourceMappingURL=apple-login-button.web.js.map
|
package/lib/module/modules/auth/sign-in/components/social-logins/apple-login-button.web.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useOvok","React","parseSignInError","isAppleCancel","loadAppleScript","signInWithApple","SocialLoginButton","jsx","_jsx","AppleServicesLoginButton","appleServicesId","appleRedirectUri","internalId","onSuccess","onError","testID","style","disabled","children","props","client","isLoading","setIsLoading","useState","handleAppleLogin","useCallback","credentials","servicesId","redirectUri","loginResponse","auth","socialLogin","cause","error","useEffect","catch","undefined","backgroundColor","onPress","AppleLoginButton"],"sourceRoot":"../../../../../../../src","sources":["modules/auth/sign-in/components/social-logins/apple-login-button.web.tsx"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,uBAAuB;AAC/C,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,gBAAgB,QAAQ,iCAA8B;AAE/D,SACEC,aAAa,EACbC,eAAe,EACfC,eAAe,QACV,kCAA+B;AAEtC,SAASC,iBAAiB,QAAQ,0BAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAM1D,MAAMC,wBAAwB,GAAGA,CAAC;EAChCC,eAAe;EACfC,gBAAgB;EAChBC,UAAU;EACVC,SAAS;EACTC,OAAO;EACPC,MAAM;EACNC,KAAK;EACLC,QAAQ;EACRC,QAAQ;EACR,GAAGC;AAC6C,CAAC,KAAK;EACtD,MAAMC,MAAM,GAAGpB,OAAO,CAAC,CAAC;EAExB,MAAM,CAACqB,SAAS,EAAEC,YAAY,CAAC,GAAGrB,KAAK,CAACsB,QAAQ,CAAC,KAAK,CAAC;EAEvD,MAAMC,gBAAgB,GAAGvB,KAAK,CAACwB,WAAW,CAAC,YAAY;IACrD,IAAI;MACFH,YAAY,CAA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@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AppleLoginButton","AppleLoginIcon","AppleLoginText","AppleLogin","Object","assign","Icon","Text"],"sourceRoot":"../../../../../../../src","sources":["modules/auth/sign-in/components/social-logins/apple-login.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,
|
|
1
|
+
{"version":3,"names":["AppleLoginButton","AppleLoginIcon","AppleLoginText","AppleLogin","Object","assign","Icon","Text"],"sourceRoot":"../../../../../../../src","sources":["modules/auth/sign-in/components/social-logins/apple-login.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,cAAc,QAAQ,uBAAoB;AACnD,SAASC,cAAc,QAAQ,uBAAoB;;AAEnD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,gBAAgB,EAAE;EACxD;EACAM,IAAI,EAAEL,cAAc;EAEpB;EACAM,IAAI,EAAEL;AACR,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useOvok } from "@ovok/core/next/react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useAppTheme } from "../../../../theme/index.js";
|
|
6
|
+
import { parseSignInError } from "../../../utils/sign-in-error.js";
|
|
7
|
+
import { startGoogleSignIn, takeGoogleIdToken } from "../../utils/google-redirect-sign-in.js";
|
|
8
|
+
import { SocialLoginButton } from "./social-login-button.js";
|
|
9
|
+
|
|
10
|
+
/** Google's sign-in page in this tab; back on the sign-in screen, the ID token it sent signs the user in. */
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
export const GoogleLoginButton = ({
|
|
13
|
+
googleIosClientId: _googleIosClientId,
|
|
14
|
+
googleWebClientId,
|
|
15
|
+
googleRedirectUri,
|
|
16
|
+
internalId,
|
|
17
|
+
onSuccess,
|
|
18
|
+
onError,
|
|
19
|
+
testID,
|
|
20
|
+
style,
|
|
21
|
+
disabled,
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
}) => {
|
|
25
|
+
const theme = useAppTheme();
|
|
26
|
+
const client = useOvok();
|
|
27
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
28
|
+
const signInWithIdToken = React.useCallback(async idToken => {
|
|
29
|
+
try {
|
|
30
|
+
setIsLoading(true);
|
|
31
|
+
const loginResponse = await client.auth.socialLogin("google", {
|
|
32
|
+
idToken,
|
|
33
|
+
internalId
|
|
34
|
+
});
|
|
35
|
+
onSuccess?.(loginResponse);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
onError?.(parseSignInError(error).error);
|
|
38
|
+
} finally {
|
|
39
|
+
setIsLoading(false);
|
|
40
|
+
}
|
|
41
|
+
}, [client, internalId, onError, onSuccess]);
|
|
42
|
+
const handleGoogleSignIn = React.useCallback(() => {
|
|
43
|
+
try {
|
|
44
|
+
startGoogleSignIn({
|
|
45
|
+
clientId: googleWebClientId,
|
|
46
|
+
redirectUri: googleRedirectUri
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
onError?.(parseSignInError(error).error);
|
|
50
|
+
}
|
|
51
|
+
}, [googleRedirectUri, googleWebClientId, onError]);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
const idToken = takeGoogleIdToken();
|
|
54
|
+
if (idToken) {
|
|
55
|
+
void signInWithIdToken(idToken);
|
|
56
|
+
}
|
|
57
|
+
}, [signInWithIdToken]);
|
|
58
|
+
return /*#__PURE__*/_jsx(SocialLoginButton, {
|
|
59
|
+
...props,
|
|
60
|
+
backgroundColor: theme.dark ? "#000" : "#fff",
|
|
61
|
+
style: style,
|
|
62
|
+
disabled: isLoading || disabled,
|
|
63
|
+
onPress: handleGoogleSignIn,
|
|
64
|
+
testID: testID,
|
|
65
|
+
children: children
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=google-login-button.web.js.map
|
package/lib/module/modules/auth/sign-in/components/social-logins/google-login-button.web.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useOvok","React","useAppTheme","parseSignInError","startGoogleSignIn","takeGoogleIdToken","SocialLoginButton","jsx","_jsx","GoogleLoginButton","googleIosClientId","_googleIosClientId","googleWebClientId","googleRedirectUri","internalId","onSuccess","onError","testID","style","disabled","children","props","theme","client","isLoading","setIsLoading","useState","signInWithIdToken","useCallback","idToken","loginResponse","auth","socialLogin","error","handleGoogleSignIn","clientId","redirectUri","useEffect","backgroundColor","dark","onPress"],"sourceRoot":"../../../../../../../src","sources":["modules/auth/sign-in/components/social-logins/google-login-button.web.tsx"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,uBAAuB;AAC/C,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,WAAW,QAAQ,4BAAmB;AAC/C,SAASC,gBAAgB,QAAQ,iCAA8B;AAE/D,SACEC,iBAAiB,EACjBC,iBAAiB,QACZ,wCAAqC;AAE5C,SAASC,iBAAiB,QAAQ,0BAAuB;;AAEzD;AAAA,SAAAC,GAAA,IAAAC,IAAA;AACA,OAAO,MAAMC,iBAAiB,GAAGA,CAAC;EAChCC,iBAAiB,EAAEC,kBAAkB;EACrCC,iBAAiB;EACjBC,iBAAiB;EACjBC,UAAU;EACVC,SAAS;EACTC,OAAO;EACPC,MAAM;EACNC,KAAK;EACLC,QAAQ;EACRC,QAAQ;EACR,GAAGC;AACsC,CAAC,KAAK;EAC/C,MAAMC,KAAK,GAAGpB,WAAW,CAAC,CAAC;EAC3B,MAAMqB,MAAM,GAAGvB,OAAO,CAAC,CAAC;EAExB,MAAM,CAACwB,SAAS,EAAEC,YAAY,CAAC,GAAGxB,KAAK,CAACyB,QAAQ,CAAC,KAAK,CAAC;EAEvD,MAAMC,iBAAiB,GAAG1B,KAAK,CAAC2B,WAAW,CACzC,MAAOC,OAAe,IAAK;IACzB,IAAI;MACFJ,YAAY,CAAC,IAAI,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,CACQ,CAAC;AAExB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GoogleIcon","GoogleLoginButton","GoogleLoginText","GoogleLogin","Object","assign","Icon","Text"],"sourceRoot":"../../../../../../../src","sources":["modules/auth/sign-in/components/social-logins/google-login.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,kBAAe;AAC1C,SAASC,iBAAiB,QAAQ,
|
|
1
|
+
{"version":3,"names":["GoogleIcon","GoogleLoginButton","GoogleLoginText","GoogleLogin","Object","assign","Icon","Text"],"sourceRoot":"../../../../../../../src","sources":["modules/auth/sign-in/components/social-logins/google-login.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,kBAAe;AAC1C,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,eAAe,QAAQ,wBAAqB;;AAErD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACJ,iBAAiB,EAAE;EAC1D;EACAK,IAAI,EAAEN,UAAU;EAEhB;EACAO,IAAI,EAAEL;AACR,CAAC,CAAC","ignoreList":[]}
|
|
@@ -9,5 +9,7 @@ export * from "./types/spacing-props.js";
|
|
|
9
9
|
export * from "./types/signin-form-forgot-password-props.js";
|
|
10
10
|
export * from "./types/login-with-separator-props.js";
|
|
11
11
|
export * from "./types/social-logins-props.js";
|
|
12
|
+
export * from "./types/google-login-props.js";
|
|
13
|
+
export * from "./types/apple-login-props.js";
|
|
12
14
|
export * from "./types/footer-props.js";
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SignIn"],"sourceRoot":"../../../../../src","sources":["modules/auth/sign-in/index.tsx"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,yBAAsB;AAE7C,cAAc,0BAAuB;AACrC,cAAc,iCAA8B;AAC5C,cAAc,6BAA0B;AACxC,cAAc,gCAA6B;AAC3C,cAAc,0BAAuB;AACrC,cAAc,8CAA2C;AACzD,cAAc,uCAAoC;AAClD,cAAc,gCAA6B;AAC3C,cAAc,yBAAsB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["SignIn"],"sourceRoot":"../../../../../src","sources":["modules/auth/sign-in/index.tsx"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,yBAAsB;AAE7C,cAAc,0BAAuB;AACrC,cAAc,iCAA8B;AAC5C,cAAc,6BAA0B;AACxC,cAAc,gCAA6B;AAC3C,cAAc,0BAAuB;AACrC,cAAc,8CAA2C;AACzD,cAAc,uCAAoC;AAClD,cAAc,gCAA6B;AAC3C,cAAc,+BAA4B;AAC1C,cAAc,8BAA2B;AACzC,cAAc,yBAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { jwtClaims } from "./jwt-claims.js";
|
|
4
|
+
const APPLE_SCRIPT_URL = "https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js";
|
|
5
|
+
const APPLE_CANCEL_ERRORS = new Set(["popup_closed_by_user", "user_cancelled_authorize"]);
|
|
6
|
+
const APPLE_REAL_USER_STATUS_UNKNOWN = 1;
|
|
7
|
+
|
|
8
|
+
/** The Apple credentials Ovok takes, without the `internalId` of the sign-in entry. */
|
|
9
|
+
|
|
10
|
+
/** The Services ID Apple signs the user in for, and the return URL registered for it. */
|
|
11
|
+
|
|
12
|
+
const browser = () => globalThis;
|
|
13
|
+
let appleScript;
|
|
14
|
+
|
|
15
|
+
/** Loads Sign in with Apple JS once; a failed load is tried again on the next call. */
|
|
16
|
+
const loadAppleScript = () => {
|
|
17
|
+
appleScript ??= new Promise((resolve, reject) => {
|
|
18
|
+
const {
|
|
19
|
+
document
|
|
20
|
+
} = browser();
|
|
21
|
+
const script = document.createElement("script");
|
|
22
|
+
script.src = APPLE_SCRIPT_URL;
|
|
23
|
+
script.async = true;
|
|
24
|
+
script.onload = () => resolve();
|
|
25
|
+
script.onerror = () => {
|
|
26
|
+
appleScript = undefined;
|
|
27
|
+
reject(new Error("Sign in with Apple could not be loaded"));
|
|
28
|
+
};
|
|
29
|
+
document.head.append(script);
|
|
30
|
+
});
|
|
31
|
+
return appleScript;
|
|
32
|
+
};
|
|
33
|
+
const appleId = () => {
|
|
34
|
+
const {
|
|
35
|
+
AppleID
|
|
36
|
+
} = browser();
|
|
37
|
+
if (!AppleID) {
|
|
38
|
+
throw new Error("Sign in with Apple is not available");
|
|
39
|
+
}
|
|
40
|
+
return AppleID;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Apple sends the name only the first time the user signs in.
|
|
44
|
+
const appleFullName = name => name ? {
|
|
45
|
+
givenName: name.firstName ?? null,
|
|
46
|
+
familyName: name.lastName ?? null,
|
|
47
|
+
middleName: null,
|
|
48
|
+
namePrefix: null,
|
|
49
|
+
nameSuffix: null,
|
|
50
|
+
nickname: null
|
|
51
|
+
} : null;
|
|
52
|
+
const appleCredentials = ({
|
|
53
|
+
authorization,
|
|
54
|
+
user
|
|
55
|
+
}) => ({
|
|
56
|
+
identityToken: authorization.id_token,
|
|
57
|
+
authorizationCode: authorization.code,
|
|
58
|
+
state: authorization.state ?? null,
|
|
59
|
+
user: jwtClaims(authorization.id_token).sub ?? "",
|
|
60
|
+
email: user?.email ?? "",
|
|
61
|
+
fullName: appleFullName(user?.name),
|
|
62
|
+
realUserStatus: APPLE_REAL_USER_STATUS_UNKNOWN
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/** Opens Apple's sign-in popup; it must run from a user gesture such as a tap. */
|
|
66
|
+
const signInWithApple = async ({
|
|
67
|
+
servicesId,
|
|
68
|
+
redirectUri
|
|
69
|
+
}) => {
|
|
70
|
+
await loadAppleScript();
|
|
71
|
+
const apple = appleId();
|
|
72
|
+
apple.auth.init({
|
|
73
|
+
clientId: servicesId,
|
|
74
|
+
scope: "name email",
|
|
75
|
+
redirectURI: redirectUri ?? browser().location.origin,
|
|
76
|
+
usePopup: true
|
|
77
|
+
});
|
|
78
|
+
return appleCredentials(await apple.auth.signIn());
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/** Whether the user closed Apple's popup or declined, which is not an error to report. */
|
|
82
|
+
const isAppleCancel = cause => typeof cause === "object" && cause !== null && APPLE_CANCEL_ERRORS.has(cause.error ?? "");
|
|
83
|
+
export { isAppleCancel, loadAppleScript, signInWithApple };
|
|
84
|
+
//# sourceMappingURL=apple-web-sign-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jwtClaims","APPLE_SCRIPT_URL","APPLE_CANCEL_ERRORS","Set","APPLE_REAL_USER_STATUS_UNKNOWN","browser","globalThis","appleScript","loadAppleScript","Promise","resolve","reject","document","script","createElement","src","async","onload","onerror","undefined","Error","head","append","appleId","AppleID","appleFullName","name","givenName","firstName","familyName","lastName","middleName","namePrefix","nameSuffix","nickname","appleCredentials","authorization","user","identityToken","id_token","authorizationCode","code","state","sub","email","fullName","realUserStatus","signInWithApple","servicesId","redirectUri","apple","auth","init","clientId","scope","redirectURI","location","origin","usePopup","signIn","isAppleCancel","cause","has","error"],"sourceRoot":"../../../../../../src","sources":["modules/auth/sign-in/utils/apple-web-sign-in.ts"],"mappings":";;AAEA,SAASA,SAAS,QAAQ,iBAAc;AAExC,MAAMC,gBAAgB,GACpB,sFAAsF;AAExF,MAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAAC,CAAC,sBAAsB,EAAE,0BAA0B,CAAC,CAAC;AACzF,MAAMC,8BAA8B,GAAG,CAAC;;AAExC;;AAGA;;AAsCA,MAAMC,OAAO,GAAGA,CAAA,KAAMC,UAAuC;AAE7D,IAAIC,WAAsC;;AAE1C;AACA,MAAMC,eAAe,GAAGA,CAAA,KAAqB;EAC3CD,WAAW,KAAK,IAAIE,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IACrD,MAAM;MAAEC;IAAS,CAAC,GAAGP,OAAO,CAAC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EAAE;EACjDC,KAAK,EAAEP,IAAI,EAAEO,KAAK,IAAI,EAAE;EACxBC,QAAQ,EAAEpB,aAAa,CAACY,IAAI,EAAEX,IAAI,CAAC;EACnCoB,cAAc,EAAE1C;AAClB,CAAC,CAAC;;AAEF;AACA,MAAM2C,eAAe,GAAG,MAAAA,CAAO;EAC7BC,UAAU;EACVC;AACe,CAAC,KAAmC;EACnD,MAAMzC,eAAe,CAAC,CAAC;EAEvB,MAAM0C,KAAK,GAAG3B,OAAO,CAAC,CAAC;EAEvB2B,KAAK,CAACC,IAAI,CAACC,IAAI,CAAC;IACdC,QAAQ,EAAEL,UAAU;IACpBM,KAAK,EAAE,YAAY;IACnBC,WAAW,EAAEN,WAAW,IAAI5C,OAAO,CAAC,CAAC,CAACmD,QAAQ,CAACC,MAAM;IACrDC,QAAQ,EAAE;EACZ,CAAC,CAAC;EAEF,OAAOvB,gBAAgB,CAAC,MAAMe,KAAK,CAACC,IAAI,CAACQ,MAAM,CAAC,CAAC,CAAC;AACpD,CAAC;;AAED;AACA,MAAMC,aAAa,GAAIC,KAAc,IACnC,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd3D,mBAAmB,CAAC4D,GAAG,CAAED,KAAK,CAAwBE,KAAK,IAAI,EAAE,CAAC;AAEpE,SACEH,aAAa,EACbpD,eAAe,EACfuC,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { jwtClaims } from "./jwt-claims.js";
|
|
4
|
+
const GOOGLE_AUTHORIZE_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
5
|
+
const GOOGLE_RETURN_PATH = "/oauth/google.html";
|
|
6
|
+
const GOOGLE_REQUEST_KEY = "ovok.google-sign-in";
|
|
7
|
+
const GOOGLE_ANSWER_KEY = "ovok.google-sign-in.answer";
|
|
8
|
+
|
|
9
|
+
/** What this tab asked Google for, kept until the answer comes back. */
|
|
10
|
+
|
|
11
|
+
/** Where the tab goes for the ID token, and which address Google returns it to. */
|
|
12
|
+
|
|
13
|
+
const browser = () => globalThis;
|
|
14
|
+
const authorizeUrl = ({
|
|
15
|
+
clientId,
|
|
16
|
+
redirectUri
|
|
17
|
+
}, {
|
|
18
|
+
state,
|
|
19
|
+
nonce
|
|
20
|
+
}) => {
|
|
21
|
+
const query = new URLSearchParams({
|
|
22
|
+
client_id: clientId,
|
|
23
|
+
redirect_uri: redirectUri,
|
|
24
|
+
response_type: "id_token",
|
|
25
|
+
scope: "openid email profile",
|
|
26
|
+
prompt: "select_account",
|
|
27
|
+
state,
|
|
28
|
+
nonce
|
|
29
|
+
});
|
|
30
|
+
return `${GOOGLE_AUTHORIZE_URL}?${query.toString()}`;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** Sends this tab to Google's sign-in page, remembering the request its answer must match. */
|
|
34
|
+
const startGoogleSignIn = ({
|
|
35
|
+
clientId,
|
|
36
|
+
redirectUri
|
|
37
|
+
}) => {
|
|
38
|
+
const {
|
|
39
|
+
sessionStorage,
|
|
40
|
+
location,
|
|
41
|
+
crypto
|
|
42
|
+
} = browser();
|
|
43
|
+
const request = {
|
|
44
|
+
state: crypto.randomUUID(),
|
|
45
|
+
nonce: crypto.randomUUID(),
|
|
46
|
+
returnTo: `${location.pathname}${location.search}`
|
|
47
|
+
};
|
|
48
|
+
sessionStorage.setItem(GOOGLE_REQUEST_KEY, JSON.stringify(request));
|
|
49
|
+
location.assign(authorizeUrl({
|
|
50
|
+
clientId,
|
|
51
|
+
redirectUri: redirectUri ?? `${location.origin}${GOOGLE_RETURN_PATH}`
|
|
52
|
+
}, request));
|
|
53
|
+
};
|
|
54
|
+
const parseRequest = stored => {
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(stored ?? "null") ?? undefined;
|
|
57
|
+
} catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const answeredIdToken = (answer, request) => {
|
|
62
|
+
const idToken = answer.get("id_token");
|
|
63
|
+
if (!request || !idToken || answer.get("state") !== request.state) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return jwtClaims(idToken).nonce === request.nonce ? idToken : undefined;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/** The ID token Google sent back for this tab's own request; the request and the answer are forgotten either way. */
|
|
70
|
+
const takeGoogleIdToken = () => {
|
|
71
|
+
const {
|
|
72
|
+
sessionStorage
|
|
73
|
+
} = browser();
|
|
74
|
+
const answer = sessionStorage.getItem(GOOGLE_ANSWER_KEY);
|
|
75
|
+
if (answer === null) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const request = parseRequest(sessionStorage.getItem(GOOGLE_REQUEST_KEY));
|
|
79
|
+
sessionStorage.removeItem(GOOGLE_ANSWER_KEY);
|
|
80
|
+
sessionStorage.removeItem(GOOGLE_REQUEST_KEY);
|
|
81
|
+
return answeredIdToken(new URLSearchParams(answer), request);
|
|
82
|
+
};
|
|
83
|
+
export { GOOGLE_ANSWER_KEY, GOOGLE_REQUEST_KEY, startGoogleSignIn, takeGoogleIdToken };
|
|
84
|
+
//# sourceMappingURL=google-redirect-sign-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jwtClaims","GOOGLE_AUTHORIZE_URL","GOOGLE_RETURN_PATH","GOOGLE_REQUEST_KEY","GOOGLE_ANSWER_KEY","browser","globalThis","authorizeUrl","clientId","redirectUri","state","nonce","query","URLSearchParams","client_id","redirect_uri","response_type","scope","prompt","toString","startGoogleSignIn","sessionStorage","location","crypto","request","randomUUID","returnTo","pathname","search","setItem","JSON","stringify","assign","origin","parseRequest","stored","parse","undefined","answeredIdToken","answer","idToken","get","takeGoogleIdToken","getItem","removeItem"],"sourceRoot":"../../../../../../src","sources":["modules/auth/sign-in/utils/google-redirect-sign-in.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,iBAAc;AAExC,M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@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** The claims web sign-in reads from a provider's JWT. */
|
|
4
|
+
|
|
5
|
+
const asClaims = value => typeof value === "object" && value !== null ? value : {};
|
|
6
|
+
|
|
7
|
+
/** A JWT's claims, read without checking the signature; Ovok verifies the token itself. */
|
|
8
|
+
const jwtClaims = jwt => {
|
|
9
|
+
try {
|
|
10
|
+
const payload = (jwt.split(".")[1] ?? "").replace(/-/g, "+").replace(/_/g, "/");
|
|
11
|
+
return asClaims(JSON.parse(atob(payload)));
|
|
12
|
+
} catch {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export { jwtClaims };
|
|
17
|
+
//# sourceMappingURL=jwt-claims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asClaims","value","jwtClaims","jwt","payload","split","replace","JSON","parse","atob"],"sourceRoot":"../../../../../../src","sources":["modules/auth/sign-in/utils/jwt-claims.ts"],"mappings":";;AAAA;;AAMA,MAAMA,QAAQ,GAAIC,KAAc,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,GAAIA,KAAK,GAAiB,CAAC,CAAC;;AAEzE;AACA,MAAMC,SAAS,GAAIC,GAAW,IAAgB;EAC5C,IAAI;IACF,MAAMC,OAAO,GAAG,CAACD,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAEC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;IAE/E,OAAON,QAAQ,CAACO,IAAI,CAACC,KAAK,CAACC,IAAI,CAACL,OAAO,CAAC,CAAC,CAAC;EAC5C,CAAC,CAAC,MAAM;IACN,OAAO,CAAC,CAAC;EACX;AACF,CAAC;AAED,SAASF,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["signOutGoogleIfNeeded","undefined"],"sourceRoot":"../../../../../src","sources":["modules/auth/utils/sign-out-google.web.ts"],"mappings":";;AAAA;AACA,OAAO,MAAMA,qBAAqB,GAAG,MAAAA,CAAA,KAA2BC,SAAS","ignoreList":[]}
|