@linked.cm/capacitor 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/README.md +20 -0
- package/.changeset/config.json +14 -0
- package/.github/workflows/pr.yml +27 -0
- package/.github/workflows/publish.yml +32 -0
- package/CHANGELOG.md +38 -0
- package/lib/esm/auth/SocialLoginClient.d.ts +40 -0
- package/lib/esm/auth/SocialLoginClient.js +240 -0
- package/lib/esm/auth/SocialLoginClient.js.map +1 -0
- package/lib/esm/backend.d.ts +26 -0
- package/lib/esm/backend.js +302 -0
- package/lib/esm/backend.js.map +1 -0
- package/lib/esm/components/LocationEnabler.d.ts +6 -0
- package/lib/esm/components/LocationEnabler.js +48 -0
- package/lib/esm/components/LocationEnabler.js.map +1 -0
- package/lib/esm/components/LocationEnabler.module.css +6 -0
- package/lib/esm/components/SafeAreaContainer.d.ts +10 -0
- package/lib/esm/components/SafeAreaContainer.js +36 -0
- package/lib/esm/components/SafeAreaContainer.js.map +1 -0
- package/lib/esm/components/SafeAreaContainer.module.css +39 -0
- package/lib/esm/components/SignInWithWhatsapp.d.ts +9 -0
- package/lib/esm/components/SignInWithWhatsapp.js +86 -0
- package/lib/esm/components/SignInWithWhatsapp.js.map +1 -0
- package/lib/esm/components/SignInWithWhatsapp.module.css +92 -0
- package/lib/esm/components/SigninWithAppleButton.d.ts +13 -0
- package/lib/esm/components/SigninWithAppleButton.js +45 -0
- package/lib/esm/components/SigninWithAppleButton.js.map +1 -0
- package/lib/esm/components/SigninWithAppleButton.module.css +22 -0
- package/lib/esm/components/SigninWithFacebookButton.d.ts +13 -0
- package/lib/esm/components/SigninWithFacebookButton.js +46 -0
- package/lib/esm/components/SigninWithFacebookButton.js.map +1 -0
- package/lib/esm/components/SigninWithFacebookButton.module.css +22 -0
- package/lib/esm/components/SigninWithGoogleButton.d.ts +13 -0
- package/lib/esm/components/SigninWithGoogleButton.js +47 -0
- package/lib/esm/components/SigninWithGoogleButton.js.map +1 -0
- package/lib/esm/components/SigninWithGoogleButton.module.css +22 -0
- package/lib/esm/data/lincd-capacitor.json +20 -0
- package/lib/esm/hooks/useAutomaticUpdates.d.ts +22 -0
- package/lib/esm/hooks/useAutomaticUpdates.js +270 -0
- package/lib/esm/hooks/useAutomaticUpdates.js.map +1 -0
- package/lib/esm/hooks/useCapacitor.d.ts +12 -0
- package/lib/esm/hooks/useCapacitor.js +68 -0
- package/lib/esm/hooks/useCapacitor.js.map +1 -0
- package/lib/esm/hooks/useNativeAppUpdate.d.ts +3 -0
- package/lib/esm/hooks/useNativeAppUpdate.js +68 -0
- package/lib/esm/hooks/useNativeAppUpdate.js.map +1 -0
- package/lib/esm/index.d.ts +13 -0
- package/lib/esm/index.js +16 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/ontologies/lincd-capacitor.d.ts +30 -0
- package/lib/esm/ontologies/lincd-capacitor.js +28 -0
- package/lib/esm/ontologies/lincd-capacitor.js.map +1 -0
- package/lib/esm/ontologies/lincd-capacitor.register.d.ts +1 -0
- package/lib/esm/ontologies/lincd-capacitor.register.js +15 -0
- package/lib/esm/ontologies/lincd-capacitor.register.js.map +1 -0
- package/lib/esm/package.d.ts +10 -0
- package/lib/esm/package.js +6 -0
- package/lib/esm/package.js.map +1 -0
- package/lib/esm/shapes/LocationUpdateAction.d.ts +11 -0
- package/lib/esm/shapes/LocationUpdateAction.js +34 -0
- package/lib/esm/shapes/LocationUpdateAction.js.map +1 -0
- package/lib/esm/shapes/index.d.ts +2 -0
- package/lib/esm/shapes/index.js +5 -0
- package/lib/esm/shapes/index.js.map +1 -0
- package/lib/esm/types.d.ts +12 -0
- package/lib/esm/types.js +1 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/esm/utils/helper.d.ts +14 -0
- package/lib/esm/utils/helper.js +39 -0
- package/lib/esm/utils/helper.js.map +1 -0
- package/package.json +103 -4
- package/readme.md +50 -0
- package/renovate.json +4 -0
- package/tests/social-login-client.test.mjs +99 -0
- package/tsconfig-esm.json +9 -0
- package/README.md +0 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { linkedPackage } from '@_linked/core/utils/Package';
|
|
2
|
+
import { createLinkedComponentFn } from '@_linked/react/utils/LinkedComponent';
|
|
3
|
+
const { linkedShape, linkedUtil, linkedOntology, registerPackageExport, registerPackageModule, getPackageShape, packageExports, packageName, } = linkedPackage('@linked.cm/capacitor');
|
|
4
|
+
const linkedComponent = createLinkedComponentFn(registerPackageExport, () => { });
|
|
5
|
+
export { linkedComponent, linkedShape, linkedUtil, linkedOntology, registerPackageExport, registerPackageModule, getPackageShape, packageExports, packageName, };
|
|
6
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,MAAM,EACJ,WAAW,EACX,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,WAAW,GACZ,GAAG,aAAa,CAAC,sBAAsB,CAAC,CAAC;AAE1C,MAAM,eAAe,GAAG,uBAAuB,CAC7C,qBAAqB,EACrB,GAAG,EAAE,GAAE,CAAC,CACT,CAAC;AAEF,OAAO,EACL,eAAe,EACf,WAAW,EACX,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,WAAW,GACZ,CAAC","sourcesContent":["import { linkedPackage } from '@_linked/core/utils/Package';\nimport { createLinkedComponentFn } from '@_linked/react/utils/LinkedComponent';\n\nconst {\n linkedShape,\n linkedUtil,\n linkedOntology,\n registerPackageExport,\n registerPackageModule,\n getPackageShape,\n packageExports,\n packageName,\n} = linkedPackage('@linked.cm/capacitor');\n\nconst linkedComponent = createLinkedComponentFn(\n registerPackageExport,\n () => {}\n);\n\nexport {\n linkedComponent,\n linkedShape,\n linkedUtil,\n linkedOntology,\n registerPackageExport,\n registerPackageModule,\n getPackageShape,\n packageExports,\n packageName,\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UpdateAction } from '@_linked/schema/shapes/UpdateAction';
|
|
2
|
+
export declare class LocationUpdateAction extends UpdateAction {
|
|
3
|
+
static targetClass: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
|
|
4
|
+
/**
|
|
5
|
+
* update user location
|
|
6
|
+
*
|
|
7
|
+
* @param latitude
|
|
8
|
+
* @param longitude
|
|
9
|
+
*/
|
|
10
|
+
static updateUserLocation(latitude: number, longitude: number): Promise<any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Server } from '@_linked/server-utils/utils/Server';
|
|
8
|
+
import { linkedShape, packageName } from '../package.js';
|
|
9
|
+
import { UpdateAction } from '@_linked/schema/shapes/UpdateAction';
|
|
10
|
+
import { lincdCapacitor } from '../ontologies/lincd-capacitor.js';
|
|
11
|
+
let LocationUpdateAction = class LocationUpdateAction extends UpdateAction {
|
|
12
|
+
/**
|
|
13
|
+
* update user location
|
|
14
|
+
*
|
|
15
|
+
* @param latitude
|
|
16
|
+
* @param longitude
|
|
17
|
+
*/
|
|
18
|
+
static async updateUserLocation(latitude, longitude) {
|
|
19
|
+
return Server.call(packageName, 'updateUserLocation', latitude, longitude)
|
|
20
|
+
.then((result) => {
|
|
21
|
+
return result;
|
|
22
|
+
})
|
|
23
|
+
.catch((err) => {
|
|
24
|
+
console.log('Update user location failed', err);
|
|
25
|
+
throw new Error(err);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
LocationUpdateAction.targetClass = lincdCapacitor.LocationUpdateAction;
|
|
30
|
+
LocationUpdateAction = __decorate([
|
|
31
|
+
linkedShape
|
|
32
|
+
], LocationUpdateAction);
|
|
33
|
+
export { LocationUpdateAction };
|
|
34
|
+
//# sourceMappingURL=LocationUpdateAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationUpdateAction.js","sourceRoot":"","sources":["../../../src/shapes/LocationUpdateAction.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAG3D,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,YAAY;IAGpD;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAgB,EAAE,SAAiB;QACjE,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,SAAS,CAAC;aACvE,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACP,CAAC;;AAjBM,gCAAW,GAAG,cAAc,CAAC,oBAAoB,AAAtC,CAAuC;AAD9C,oBAAoB;IADhC,WAAW;GACC,oBAAoB,CAmBhC","sourcesContent":["import { Server } from '@_linked/server-utils/utils/Server';\nimport { linkedShape, packageName } from '../package.js';\nimport { UpdateAction } from '@_linked/schema/shapes/UpdateAction';\nimport { lincdCapacitor } from '../ontologies/lincd-capacitor.js';\n\n@linkedShape\nexport class LocationUpdateAction extends UpdateAction {\n static targetClass = lincdCapacitor.LocationUpdateAction;\n\n /**\n * update user location\n *\n * @param latitude\n * @param longitude\n */\n static async updateUserLocation(latitude: number, longitude: number) {\n return Server.call(packageName, 'updateUserLocation', latitude, longitude)\n .then((result) => {\n return result;\n })\n .catch((err) => {\n console.log('Update user location failed', err);\n throw new Error(err);\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Side-effect imports only. Apps register every shape with import '@linked.cm/capacitor/shapes/index'.
|
|
2
|
+
// The register import stays here so that path registers the ontology without loading the components.
|
|
3
|
+
import '../ontologies/lincd-capacitor.register.js';
|
|
4
|
+
import './LocationUpdateAction.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shapes/index.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,qGAAqG;AACrG,OAAO,2CAA2C,CAAC;AACnD,OAAO,2BAA2B,CAAC","sourcesContent":["// Side-effect imports only. Apps register every shape with import '@linked.cm/capacitor/shapes/index'.\n// The register import stays here so that path registers the ontology without loading the components.\nimport '../ontologies/lincd-capacitor.register.js';\nimport './LocationUpdateAction.js';\n"]}
|
package/lib/esm/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["declare module '*.module.css' {\n const classes: { [key: string]: string };\n export default classes;\n}\n\ndeclare module '*.module.scss' {\n const classes: { [key: string]: string };\n export default classes;\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On Android dev builds, image URLs still point at localhost. Rewrite them to
|
|
3
|
+
* SITE_ROOT so the device can load them. Other platforms keep the original URL.
|
|
4
|
+
*/
|
|
5
|
+
export declare function replaceLocalhostWithSiteRoot(croppedImage: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Normalize telephone strings for WhatsApp OTP sign-in identity lookup.
|
|
8
|
+
*
|
|
9
|
+
* Examples:
|
|
10
|
+
* - `"+1 813-381-1122"` -> `"+18133811122"`
|
|
11
|
+
* - `"(+62) 813 3811 1222"` -> `"+6281338111222"`
|
|
12
|
+
* - `"001234567890"` -> `"+1234567890"`
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeTelephone(value: unknown): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Capacitor } from '@capacitor/core';
|
|
2
|
+
/**
|
|
3
|
+
* On Android dev builds, image URLs still point at localhost. Rewrite them to
|
|
4
|
+
* SITE_ROOT so the device can load them. Other platforms keep the original URL.
|
|
5
|
+
*/
|
|
6
|
+
export function replaceLocalhostWithSiteRoot(croppedImage) {
|
|
7
|
+
let imageSrc = croppedImage;
|
|
8
|
+
if (imageSrc &&
|
|
9
|
+
process.env.NODE_ENV !== 'production' &&
|
|
10
|
+
Capacitor.getPlatform() === 'android') {
|
|
11
|
+
const siteRoot = process.env.SITE_ROOT;
|
|
12
|
+
if (siteRoot && imageSrc.includes('localhost')) {
|
|
13
|
+
imageSrc = imageSrc.replace(/http:\/\/localhost:\d+/, siteRoot);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return imageSrc;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Normalize telephone strings for WhatsApp OTP sign-in identity lookup.
|
|
20
|
+
*
|
|
21
|
+
* Examples:
|
|
22
|
+
* - `"+1 813-381-1122"` -> `"+18133811122"`
|
|
23
|
+
* - `"(+62) 813 3811 1222"` -> `"+6281338111222"`
|
|
24
|
+
* - `"001234567890"` -> `"+1234567890"`
|
|
25
|
+
*/
|
|
26
|
+
export function normalizeTelephone(value) {
|
|
27
|
+
const raw = String(value || '').trim();
|
|
28
|
+
if (!raw)
|
|
29
|
+
return '';
|
|
30
|
+
// Keep leading '+' when present; drop other non-digit characters (spaces, dashes, parentheses).
|
|
31
|
+
let cleaned = raw.replace(/[^\d+]/g, '');
|
|
32
|
+
// Some sources use 00 prefix for international dialing.
|
|
33
|
+
if (cleaned.startsWith('00')) {
|
|
34
|
+
cleaned = `+${cleaned.slice(2)}`;
|
|
35
|
+
}
|
|
36
|
+
// If still no '+', leave as-is (some legacy records may be stored without it).
|
|
37
|
+
return cleaned;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../src/utils/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,YAAoB;IAC/D,IAAI,QAAQ,GAAG,YAAY,CAAC;IAC5B,IACE,QAAQ;QACR,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;QACrC,SAAS,CAAC,WAAW,EAAE,KAAK,SAAS,EACrC,CAAC;QACD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACvC,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/C,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IAEpB,gGAAgG;IAChG,IAAI,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAEzC,wDAAwD;IACxD,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACnC,CAAC;IAED,+EAA+E;IAC/E,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { Capacitor } from '@capacitor/core';\n\n/**\n * On Android dev builds, image URLs still point at localhost. Rewrite them to\n * SITE_ROOT so the device can load them. Other platforms keep the original URL.\n */\nexport function replaceLocalhostWithSiteRoot(croppedImage: string): string {\n let imageSrc = croppedImage;\n if (\n imageSrc &&\n process.env.NODE_ENV !== 'production' &&\n Capacitor.getPlatform() === 'android'\n ) {\n const siteRoot = process.env.SITE_ROOT;\n if (siteRoot && imageSrc.includes('localhost')) {\n imageSrc = imageSrc.replace(/http:\\/\\/localhost:\\d+/, siteRoot);\n }\n }\n\n return imageSrc;\n}\n\n/**\n * Normalize telephone strings for WhatsApp OTP sign-in identity lookup.\n *\n * Examples:\n * - `\"+1 813-381-1122\"` -> `\"+18133811122\"`\n * - `\"(+62) 813 3811 1222\"` -> `\"+6281338111222\"`\n * - `\"001234567890\"` -> `\"+1234567890\"`\n */\nexport function normalizeTelephone(value: unknown): string {\n const raw = String(value || '').trim();\n if (!raw) return '';\n\n // Keep leading '+' when present; drop other non-digit characters (spaces, dashes, parentheses).\n let cleaned = raw.replace(/[^\\d+]/g, '');\n\n // Some sources use 00 prefix for international dialing.\n if (cleaned.startsWith('00')) {\n cleaned = `+${cleaned.slice(2)}`;\n }\n\n // If still no '+', leave as-is (some legacy records may be stored without it).\n return cleaned;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,105 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linked.cm/capacitor",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"description": "Native app helpers for sign-in, safe area, location, and updates.",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "",
|
|
6
|
+
"email": "",
|
|
7
|
+
"url": ""
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+ssh://git@github.com/linked-cm/capacitor.git"
|
|
12
|
+
},
|
|
13
|
+
"version": "0.2.0",
|
|
14
|
+
"linkedPackage": true,
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "lib/esm/index.js",
|
|
17
|
+
"module": "lib/esm/index.js",
|
|
18
|
+
"//types": "Correct as written, do not 'fix' it: typesVersions below is applied to the types field too, so \"index.d.ts\" resolves to lib/esm/index.d.ts. Writing that literal path applies the mapping twice (lib/esm/lib/esm/index.d.ts) and breaks node10 resolution. Verify with ts.resolveModuleName under node10 AND bundler, not by looking for the file on disk.",
|
|
19
|
+
"types": "index.d.ts",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"start": "linked dev",
|
|
23
|
+
"test": "npm run build-esm && node --test tests/*.test.mjs",
|
|
24
|
+
"build": "rimraf ./lib && npm run build-esm && npm run copy-to-lib",
|
|
25
|
+
"build-esm": "echo \"compiling ESM\" && rimraf ./lib/esm && tsc -p tsconfig-esm.json",
|
|
26
|
+
"copy-to-lib": "echo 'copying CSS + JSON assets to lib folder' && copyfiles -u 1 'src/**/*.css' 'src/**/*.json' lib/esm"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"linked",
|
|
30
|
+
"linked data",
|
|
31
|
+
"semantic web",
|
|
32
|
+
"web3"
|
|
33
|
+
],
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./lib/esm/index.d.ts",
|
|
37
|
+
"import": "./lib/esm/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./*.js": {
|
|
40
|
+
"types": "./lib/esm/*.d.ts",
|
|
41
|
+
"import": "./lib/esm/*.js"
|
|
42
|
+
},
|
|
43
|
+
"./*": {
|
|
44
|
+
"types": "./lib/esm/*.d.ts",
|
|
45
|
+
"import": "./lib/esm/*.js"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"typesVersions": {
|
|
49
|
+
"*": {
|
|
50
|
+
"*": [
|
|
51
|
+
"lib/esm/*"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@_linked/auth": "^1.2.3",
|
|
57
|
+
"@_linked/core": "^2.27.0",
|
|
58
|
+
"@_linked/primitives": "^1.8.0",
|
|
59
|
+
"@_linked/react": "^2.0.0",
|
|
60
|
+
"@_linked/schema": "^1.5.0",
|
|
61
|
+
"@_linked/server-utils": "~1.0",
|
|
62
|
+
"@_linked/sioc": "^1.4.0",
|
|
63
|
+
"google-libphonenumber": "3.2.33",
|
|
64
|
+
"react-international-phone": "4.0.4",
|
|
65
|
+
"react-router-dom": "^6.22.3"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@_linked/cli": "^1.2",
|
|
69
|
+
"@capacitor/app": "^7.0.0",
|
|
70
|
+
"@capacitor/core": "^7.0.0",
|
|
71
|
+
"@capacitor/dialog": "^7.0.0",
|
|
72
|
+
"@capacitor/geolocation": "^7.0.0",
|
|
73
|
+
"@capacitor/preferences": "^7.0.0",
|
|
74
|
+
"@capawesome/capacitor-app-update": "^7.2.0",
|
|
75
|
+
"@capgo/capacitor-social-login": "7.20.0",
|
|
76
|
+
"@capgo/capacitor-updater": "^7.4.0",
|
|
77
|
+
"@changesets/changelog-github": "^0.5.2",
|
|
78
|
+
"@changesets/cli": "^2.29.8",
|
|
79
|
+
"@tolgee/react": "^5.33.0",
|
|
80
|
+
"@types/node": "^20.12.7",
|
|
81
|
+
"@types/react": "^19.3.0",
|
|
82
|
+
"@types/react-dom": "^19.3.0",
|
|
83
|
+
"capacitor-plugin-safe-area": "^4.0.3",
|
|
84
|
+
"copyfiles": "^2.4.1",
|
|
85
|
+
"rimraf": "^5.0.7",
|
|
86
|
+
"typescript": "^5.7.3",
|
|
87
|
+
"typescript-plugin-css-modules": "^5.1.0"
|
|
88
|
+
},
|
|
89
|
+
"peerDependencies": {
|
|
90
|
+
"@capacitor/app": ">=7 <8",
|
|
91
|
+
"@capacitor/core": ">=7 <8",
|
|
92
|
+
"@capacitor/dialog": ">=7 <8",
|
|
93
|
+
"@capacitor/geolocation": ">=7 <8",
|
|
94
|
+
"@capacitor/preferences": ">=7 <8",
|
|
95
|
+
"@capawesome/capacitor-app-update": ">=7 <8",
|
|
96
|
+
"@capgo/capacitor-social-login": "7.20.0",
|
|
97
|
+
"@capgo/capacitor-updater": ">=7 <8",
|
|
98
|
+
"@tolgee/react": ">=5 <6",
|
|
99
|
+
"capacitor-plugin-safe-area": ">=4 <5"
|
|
100
|
+
},
|
|
101
|
+
"publishConfig": {
|
|
102
|
+
"access": "public"
|
|
103
|
+
},
|
|
104
|
+
"packageManager": "npm@12.2.0"
|
|
105
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @linked.cm/capacitor
|
|
2
|
+
|
|
3
|
+
Native app helpers for social sign-in, WhatsApp one-time codes, safe area, location, and store or bundle updates.
|
|
4
|
+
|
|
5
|
+
The location term stays on `http://lincd.org/ont/lincd-capacitor/`. Shape registration uses `@linked.cm/capacitor`.
|
|
6
|
+
|
|
7
|
+
## Public entry points
|
|
8
|
+
|
|
9
|
+
| Import | What it is |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `@linked.cm/capacitor` | Social login helpers: `loginWithGoogle`, `loginWithApple`, `loginWithFacebook`, `SocialLoginError` |
|
|
12
|
+
| `@linked.cm/capacitor/components/SigninWithGoogleButton` | Google sign-in button |
|
|
13
|
+
| `@linked.cm/capacitor/components/SigninWithAppleButton` | Apple sign-in button. Renders nothing on Android |
|
|
14
|
+
| `@linked.cm/capacitor/components/SigninWithFacebookButton` | Facebook sign-in button |
|
|
15
|
+
| `@linked.cm/capacitor/components/SignInWithWhatsapp` | `SigninWithWhatsappButton`, phone then 6-digit code |
|
|
16
|
+
| `@linked.cm/capacitor/components/LocationEnabler` | Switch that stores the device position |
|
|
17
|
+
| `@linked.cm/capacitor/components/SafeAreaContainer` | Native safe-area insets as CSS variables |
|
|
18
|
+
| `@linked.cm/capacitor/hooks/useCapacitor` | `CapacitorProvider` for deep links and native token storage |
|
|
19
|
+
| `@linked.cm/capacitor/hooks/useAutomaticUpdates` | OTA bundle updates and a maintenance check |
|
|
20
|
+
| `@linked.cm/capacitor/hooks/useNativeAppUpdate` | Store update prompt on iOS and Android |
|
|
21
|
+
| `@linked.cm/capacitor/shapes/LocationUpdateAction` | `LocationUpdateAction.updateUserLocation` |
|
|
22
|
+
| `@linked.cm/capacitor/shapes/index` | Registers the location shape without loading the components |
|
|
23
|
+
| `@linked.cm/capacitor/utils/helper` | `normalizeTelephone` and `replaceLocalhostWithSiteRoot` |
|
|
24
|
+
| `@linked.cm/capacitor/backend` | `CapacitorBackendProvider` |
|
|
25
|
+
|
|
26
|
+
## Sign-in
|
|
27
|
+
|
|
28
|
+
Google, Apple, and Facebook buttons call `auth.signinOAuth` and pass the result to `onCallback`. A cancelled prompt does not call `onCallback`. Any other failure calls it with `{ error }`.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { SigninWithGoogleButton } from '@linked.cm/capacitor/components/SigninWithGoogleButton';
|
|
32
|
+
|
|
33
|
+
<SigninWithGoogleButton onCallback={(result) => {}} />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Google web login needs `GOOGLE_CLIENT_ID` and `SITE_ROOT` (the callback is `{SITE_ROOT}/signin`). Apple on the web needs `APPLE_SIGN_IN_CLIENT_ID` and `APPLE_SIGN_IN_REDIRECT_URI`. Facebook needs `FACEBOOK_CLIENT_ID`.
|
|
37
|
+
|
|
38
|
+
WhatsApp sign-in asks the backend to send a code, then validates it. The server reads:
|
|
39
|
+
|
|
40
|
+
- `WA_D360_API_KEY`
|
|
41
|
+
- `WA_D360_USERNAME`
|
|
42
|
+
- `WA_D360_PASSWORD`
|
|
43
|
+
- `WA_D360_TEMPLATE_NAMESPACE`
|
|
44
|
+
- `WA_D360_TEMPLATE_NAME`
|
|
45
|
+
|
|
46
|
+
## Location and updates
|
|
47
|
+
|
|
48
|
+
`LocationEnabler` requests the device position only when the switch turns on, then calls `LocationUpdateAction.updateUserLocation`. Turning the switch off clears `enabledLocationServices` on the current account.
|
|
49
|
+
|
|
50
|
+
`useAutomaticUpdates` runs on iOS and Android. It confirms the current bundle, checks the native store version, polls `{SITE_ROOT}/__health`, and downloads a newer bundle when the server is up. `IOS_APP_STORE_ID` is the numeric store id used when opening the store.
|
package/renovate.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import test from 'node:test';
|
|
4
|
+
import {
|
|
5
|
+
buildGoogleLoginOptions,
|
|
6
|
+
createAppleNonce,
|
|
7
|
+
classifySocialLoginError,
|
|
8
|
+
resolveGoogleRedirectUri,
|
|
9
|
+
} from '../lib/esm/auth/SocialLoginClient.js';
|
|
10
|
+
|
|
11
|
+
test('resolves the Google web callback from SITE_ROOT', () => {
|
|
12
|
+
assert.equal(
|
|
13
|
+
resolveGoogleRedirectUri('https://example.com/', 'web'),
|
|
14
|
+
'https://example.com/signin'
|
|
15
|
+
);
|
|
16
|
+
assert.equal(resolveGoogleRedirectUri(undefined, 'android'), undefined);
|
|
17
|
+
assert.throws(
|
|
18
|
+
() => resolveGoogleRedirectUri(undefined, 'web'),
|
|
19
|
+
(error) => error?.kind === 'configuration'
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('omits custom Google scopes on Android', () => {
|
|
24
|
+
assert.deepEqual(buildGoogleLoginOptions('android', ['email']), {});
|
|
25
|
+
assert.deepEqual(buildGoogleLoginOptions('ios', ['email']), {
|
|
26
|
+
scopes: ['email'],
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('keeps the SocialLogin proxy nested inside the imported module', async () => {
|
|
31
|
+
const source = await readFile(
|
|
32
|
+
new URL('../lib/esm/auth/SocialLoginClient.js', import.meta.url),
|
|
33
|
+
'utf8'
|
|
34
|
+
);
|
|
35
|
+
assert.match(source, /pluginModulePromise\s*=\s*import\(['"]@capgo\/capacitor-social-login['"]\)/);
|
|
36
|
+
assert.doesNotMatch(source, /return\s+SocialLogin\s*;/);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('creates a 32-byte base64url Apple nonce without padding', () => {
|
|
40
|
+
assert.match(createAppleNonce(), /^[A-Za-z0-9_-]{43}$/);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('classifies cancellation and network failures', () => {
|
|
44
|
+
for (const cancellation of [
|
|
45
|
+
new Error('User cancelled'),
|
|
46
|
+
new Error('Popup closed'),
|
|
47
|
+
new Error('popup_closed_by_user'),
|
|
48
|
+
{ error: 'user_cancelled_authorize' },
|
|
49
|
+
new Error(
|
|
50
|
+
'The operation couldn’t be completed. (AuthenticationServices.AuthorizationError error 1001.)'
|
|
51
|
+
),
|
|
52
|
+
new Error('access_denied'),
|
|
53
|
+
{ message: 'The user dismissed the sign-in dialog' },
|
|
54
|
+
{ code: 12501, message: 'Google Sign-In failed' },
|
|
55
|
+
{ errorCode: 'GetCredentialCancellationException' },
|
|
56
|
+
]) {
|
|
57
|
+
assert.equal(classifySocialLoginError(cancellation).kind, 'cancelled');
|
|
58
|
+
}
|
|
59
|
+
assert.equal(
|
|
60
|
+
classifySocialLoginError(new Error('Network offline')).kind,
|
|
61
|
+
'network'
|
|
62
|
+
);
|
|
63
|
+
assert.match(
|
|
64
|
+
classifySocialLoginError(new Error('Network offline')).message,
|
|
65
|
+
/internet connection/i
|
|
66
|
+
);
|
|
67
|
+
assert.equal(
|
|
68
|
+
classifySocialLoginError(new Error('Invalid client configuration')).kind,
|
|
69
|
+
'provider'
|
|
70
|
+
);
|
|
71
|
+
assert.equal(
|
|
72
|
+
classifySocialLoginError(new Error('Invalid client configuration')).message,
|
|
73
|
+
"We couldn't complete sign-in. Please try again or use another sign-in method."
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
for (const provider of ['Apple', 'Google', 'Facebook']) {
|
|
78
|
+
test(`${provider} button guards duplicate login and forwards direct props`, async () => {
|
|
79
|
+
const source = await readFile(
|
|
80
|
+
new URL(
|
|
81
|
+
`../lib/esm/components/SigninWith${provider}Button.js`,
|
|
82
|
+
import.meta.url
|
|
83
|
+
),
|
|
84
|
+
'utf8'
|
|
85
|
+
);
|
|
86
|
+
assert.match(source, /loginInFlight\.current/);
|
|
87
|
+
assert.match(source, /if \(result\)\s+onCallback\(result\)/);
|
|
88
|
+
assert.match(source, /\.\.\.buttonProps/);
|
|
89
|
+
assert.match(source, /disabled:\s*loading\s*\|\|\s*disabledByCaller/);
|
|
90
|
+
assert.ok(
|
|
91
|
+
source.indexOf('onClick:') > source.indexOf('...buttonProps'),
|
|
92
|
+
'forwarded props must not override the internal login handler'
|
|
93
|
+
);
|
|
94
|
+
assert.ok(
|
|
95
|
+
source.indexOf('onCallback(result)') > source.indexOf('finally'),
|
|
96
|
+
'consumer callback must run outside provider error classification'
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
}
|
package/README.md
DELETED